From 44e1993fa5fa985b5a761b1c935019aa8e0cf626 Mon Sep 17 00:00:00 2001 From: Ricky Reusser <572717+rreusser@users.noreply.github.com> Date: Fri, 17 Jan 2025 10:44:38 -0800 Subject: [PATCH 1/7] feat: add lapack/base/zlaset --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/zlaset/README.md | 307 +++++++ .../lapack/base/zlaset/benchmark/benchmark.js | 104 +++ .../zlaset/benchmark/benchmark.ndarray.js | 105 +++ .../@stdlib/lapack/base/zlaset/docs/repl.txt | 112 +++ .../lapack/base/zlaset/docs/types/index.d.ts | 132 +++ .../lapack/base/zlaset/docs/types/test.ts | 348 ++++++++ .../lapack/base/zlaset/examples/index.js | 44 + .../@stdlib/lapack/base/zlaset/lib/base.js | 783 ++++++++++++++++++ .../@stdlib/lapack/base/zlaset/lib/index.js | 90 ++ .../@stdlib/lapack/base/zlaset/lib/main.js | 35 + .../@stdlib/lapack/base/zlaset/lib/ndarray.js | 104 +++ .../@stdlib/lapack/base/zlaset/lib/zlaset.js | 125 +++ .../@stdlib/lapack/base/zlaset/package.json | 69 ++ .../@stdlib/lapack/base/zlaset/test/test.js | 82 ++ .../lapack/base/zlaset/test/test.ndarray.js | 532 ++++++++++++ .../lapack/base/zlaset/test/test.zlaset.js | 346 ++++++++ 16 files changed, 3318 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/zlaset/README.md create mode 100644 lib/node_modules/@stdlib/lapack/base/zlaset/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/lapack/base/zlaset/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/zlaset/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/zlaset/examples/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/zlaset/lib/base.js create mode 100644 lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/zlaset/lib/main.js create mode 100644 lib/node_modules/@stdlib/lapack/base/zlaset/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/zlaset/lib/zlaset.js create mode 100644 lib/node_modules/@stdlib/lapack/base/zlaset/package.json create mode 100644 lib/node_modules/@stdlib/lapack/base/zlaset/test/test.js create mode 100644 lib/node_modules/@stdlib/lapack/base/zlaset/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/zlaset/test/test.zlaset.js diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/README.md b/lib/node_modules/@stdlib/lapack/base/zlaset/README.md new file mode 100644 index 000000000000..2a6ff07a2bcb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/README.md @@ -0,0 +1,307 @@ + + +# zlaset + +> Initialize the off-diagonal elements and the diagonal elements of a matrix to given values. + +
+ +## Usage + +```javascript +var zlaset = require( '@stdlib/lapack/base/zlaset' ); +``` + +#### zlaset( order, uplo, M, N, alpha, beta, A, LDA ) + +Initializes the off-diagonal elements and the diagonal elements of a matrix to given values. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); + +var A = new Complex128Array( 4 ); +var alpha = new Complex128( 1.0, 2.0 ); +var beta = new Complex128( 3.0, 4.0 ); + +zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, 2 ); + +var z = A.get( 0 ); +// returns + +var re = real( z ); +// returns 3.0 + +var im = imag( z ); +// returns 4.0 +``` + +The function has the following parameters: + +- **order**: storage layout. +- **uplo**: specifies whether to set the upper or lower triangular/trapezoidal part of a matrix `A`. +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **alpha**: value assigned to off-diagonal elements. +- **beta**: value assigned to diagonal elements. +- **A**: input [`Complex128Array`][@stdlib/array/complex128]. +- **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 Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); + +// Initial array... +var A0 = new Complex128Array( 5 ); + +// Create offset view... +var A1 = new Complex128Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var alpha = new Complex128( 1.0, 2.0 ); +var beta = new Complex128( 3.0, 4.0 ); + +zlaset( 'row-major', 'all', 2, 2, alpha, beta, A1, 2 ); + +var z = A0.get( 1 ); +// returns + +var re = real( z ); +// returns 3.0 + +var im = imag( z ); +// returns 4.0 +``` + +#### zlaset.ndarray( uplo, M, N, alpha, beta, A, sa1, sa2, oa ) + +Initializes the off-diagonal elements and the diagonal elements of a matrix to given values using alternative indexing semantics. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); + +var A = new Complex128Array( 4 ); + +var alpha = new Complex128( 1.0, 2.0 ); +var beta = new Complex128( 3.0, 4.0 ); + +zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, 0 ); + +var z = A.get( 0 ); +// returns + +var re = real( z ); +// returns 3.0 + +var im = imag( z ); +// returns 4.0 +``` + +The function has the following parameters: + +- **uplo**: specifies whether to set the upper or lower triangular/trapezoidal part of a matrix `A`. +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **alpha**: value assigned to off-diagonal elements. +- **beta**: value assigned to diagonal elements. +- **A**: input [`Complex128Array`][@stdlib/array/complex128]. +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); + +var A = new Complex128Array( 5 ); + +var alpha = new Complex128( 1.0, 2.0 ); +var beta = new Complex128( 3.0, 4.0 ); + +zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, 1 ); + +var z = A.get( 1 ); +// returns + +var re = real( z ); +// returns 3.0 + +var im = imag( z ); +// returns 4.0 +``` + +
+ + + +
+ +## Notes + +- `zlaset()` corresponds to the [LAPACK][lapack] routine [`zlaset`][lapack-zlaset]. + +
+ + + +
+ +## Examples + + + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); + +var shape = [ 5, 8 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +var N = numel( shape ); + +var A = new Complex128Array( N ); +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var alpha = new Complex128( 1.0, 2.0 ); +console.log(alpha); + +var beta = new Complex128( 3.0, 4.0 ); +console.log(beta); + +zlaset( order, 'all', shape[ 0 ], shape[ 1 ], alpha, beta, A, strides[ 0 ] ); +console.log( ndarray2array( A, shape, strides, 0, order ) ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/zlaset/benchmark/benchmark.js new file mode 100644 index 000000000000..682e13b9d9be --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/benchmark/benchmark.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +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 zlaset = require( './../lib/zlaset.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var alpha; + var beta; + var A; + + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + A = new Complex128Array( N*N ); + 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 = zlaset( 'column-major', 'all', N, N, alpha, beta, 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/zlaset/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/zlaset/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..b8cd5556320a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/benchmark/benchmark.ndarray.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 dlacpy = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var opts; + var A; + var B; + + opts = { + 'dtype': 'float64' + }; + + A = uniform( N*N, -10.0, 10.0, opts ); + B = uniform( N*N, -10.0, 10.0, opts ); + 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 = dlacpy( 'all', N, N, A, 1, N, 0, B, 1, 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(); diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/repl.txt new file mode 100644 index 000000000000..f1441e77985d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/repl.txt @@ -0,0 +1,112 @@ + +{{alias}}( order, uplo, M, N, alpha, beta, A, LDA ) + Initializes the off-diagonal elements and the diagonal elements of a matrix + `A` to given values. + + 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 to copy the upper or lower triangular/trapezoidal part + of a matrix `A`. + + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + alpha: Complex128 + Value assigned to off-diagonal elements. + + beta: Complex128 + Value assigned to diagonal elements. + + A: Complex128Array + Input matrix `A`. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + Returns + ------- + A: Complex128Array + Output matrix. + + Examples + -------- + > var A = new {{alias:@stdlib/array/complex128}}( 4 ); + > var alpha = new {{alias:@stdlib/complex/float64/ctor}}( 1.0, 2.0 ); + > var beta = new {{alias:@stdlib/complex/float64/ctor}}( 3.0, 4.0 ); + > {{alias}}( 'row-major', 'all', 2, 2, alpha, beta, A, 2 ); + > var z = A.get( 0 ); + > {{alias:@stdlib/complex/float64/real}}( z ) + 3.0 + > {{alias:@stdlib/complex/float64/imag}}( z ) + 4.0 + + +{{alias}}.ndarray( uplo, M, N, alpha, beta, A, sa1, sa2, oa ) + Initializes the off-diagonal elements and the diagonal elements of a matrix + `A` to given values 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 + ---------- + uplo: string + Specifies whether to copy the upper or lower triangular/trapezoidal part + of a matrix `A`. + + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + alpha: Complex128 + Value assigned to off-diagonal elements. + + beta: Complex128 + Value assigned to diagonal elements. + + A: Complex128Array + Input matrix `A`. + + sa1: integer + Stride of the first dimension of `A`. + + sa2: integer + Stride of the second dimension of `A`. + + oa: integer + Starting index for `A`. + + Returns + ------- + A: Complex128Array + Output matrix. + + Examples + -------- + > var A = new {{alias:@stdlib/array/complex128}}( 5 ); + > var alpha = new {{alias:@stdlib/complex/float64/ctor}}( 1.0, 2.0 ); + > var beta = new {{alias:@stdlib/complex/float64/ctor}}( 3.0, 4.0 ); + > {{alias}}.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, 1 ); + > var z = A.get( 1 ); + > {{alias:@stdlib/complex/float64/real}}( z ) + 3.0 + > {{alias:@stdlib/complex/float64/imag}}( z ) + 4.0 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/index.d.ts new file mode 100644 index 000000000000..0451298a9509 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/index.d.ts @@ -0,0 +1,132 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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 { Complex128Array } from '@stdlib/types/array'; +import { Complex128 } from '@stdlib/types/complex'; +import { Layout } from '@stdlib/types/blas'; + +/** +* Interface describing `zlaset`. +*/ +interface Routine { + /** + * Initializes the off-diagonal elements and the diagonal elements of a matrix to given values. + * + * @param order - storage layout of `A` + * @param uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` + * @param M - number of rows in matrix `A` + * @param N - number of columns in matrix `A` + * @param alpha - value assigned to off-diagonal elements + * @param beta - value assigned to diagonal elements + * @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 Complex128Array = require( '@stdlib/array/complex128' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * + * var A = new Complex128Array( 4 ); + * var alpha = new Complex128( 1.0, 2.0 ); + * var beta = new Complex128( 3.0, 4.0 ); + * + * zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, 2 ); + * // A => [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 1.0, 2.0 ] + */ + ( order: Layout, uplo: string, M: number, N: number, alpha: Complex128, beta: Complex128, A: Complex128Array, LDA: number ): Complex128Array; + + /** + * Initializes the off-diagonal elements and the diagonal elements of a matrix to given values. + * + * @param uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` + * @param M - number of rows in matrix `A` + * @param N - number of columns in matrix `A` + * @param alpha - value assigned to off-diagonal elements + * @param beta - value assigned to diagonal elements + * @param A - input matrix + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @param offsetA - starting index for `A` + * @returns `A` + * + * @example + * var Complex128Array = require( '@stdlib/array/float64' ); + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * var real = require( '@stdlib/complex/float64/real' ); + * var imag = require( '@stdlib/complex/float64/imag' ); + * + * var A = new Complex128Array( 4 ); + * + * var alpha = new Complex128( 1.0, 2.0 ); + * var beta = new Complex128( 3.0, 4.0 ); + * + * zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, 0 ); + * // A => [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 1.0, 2.0 ] + */ + ndarray( uplo: string, M: number, N: number, alpha: Complex128, beta: Complex128, A: Complex128Array, strideA1: number, strideA2: number, offsetA: number ): Complex128Array; +} + +/** +* Initializes the off-diagonal elements and the diagonal elements of a matrix to given values. +* +* @param order - storage layout of `A` +* @param uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param M - number of rows in matrix `A` +* @param N - number of columns in matrix `A` +* @param alpha - value assigned to off-diagonal elements +* @param beta - value assigned to diagonal elements +* @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 Complex128Array = require( '@stdlib/array/complex128' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, 2 ); +* // A => [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 1.0, 2.0 ] +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var A = new Complex128Array( 5 ); +* +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* zlaset.ndarray( 'all', 2, 2, A, 2, 1, 1 ); +* // A => [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 1.0, 2.0 ] +*/ +declare var zlaset: Routine; + + +// EXPORTS // + +export = zlaset; diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/test.ts new file mode 100644 index 000000000000..3d8b7ff68a86 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/test.ts @@ -0,0 +1,348 @@ +/* +* @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 Complex128Array = require( '@stdlib/array/complex128' ); +import Complex128 = require( '@stdlib/complex/float64/ctor' ); +import zlaset = require( './index' ); + + +// TESTS // + +// The function returns a Complex128Array... +{ + const A = new Complex128Array( 4 ); + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, 2 ); // $ExpectType Complex128Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Complex128Array( 4 ); + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset( 5, 'all', 2, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( true, 'all', 2, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( false, 'all', 2, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( null, 'all', 2, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( void 0, 'all', 2, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( [], 'all', 2, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( {}, 'all', 2, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( ( x: number ): number => x, 'all', 2, 2, alpha, beta, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const A = new Complex128Array( 4 ); + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset( 'row-major', 5, 2, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', true, 2, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', false, 2, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', null, 2, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', void 0, 2, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', [], 2, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', {}, 2, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', ( x: number ): number => x, 2, 2, alpha, beta, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Complex128Array( 4 ); + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset( 'row-major', 'all', '5', 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', true, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', false, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', null, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', void 0, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', [], 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', {}, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', ( x: number ): number => x, 2, alpha, beta, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Complex128Array( 4 ); + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset( 'row-major', 'all', 2, '5', alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, true, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, false, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, null, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, void 0, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, [], alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, {}, alpha, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, ( x: number ): number => x, alpha, beta, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Complex128... +{ + const A = new Complex128Array( 4 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset( 'row-major', 'all', 2, 2, '5', beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, 5, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, true, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, false, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, null, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, void 0, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, [], beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, {}, beta, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, ( x: number ): number => x, beta, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Complex128... +{ + const A = new Complex128Array( 4 ); + const alpha = new Complex128( 1.0, 2.0 ); + + zlaset( 'row-major', 'all', 2, 2, alpha, '5', A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, true, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, false, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, null, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, void 0, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, [], A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, {}, A, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, ( x: number ): number => x, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Complex128Array... +{ + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset( 'row-major', 'all', 2, 2, alpha, beta, '5', 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, 5, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, true, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, false, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, null, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, void 0, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, [], 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, {}, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, ( x: number ): number => x, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const A = new Complex128Array( 4 ); + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, '5' ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, true ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, false ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, null ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, void 0 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, [] ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, {} ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Complex128Array( 4 ); + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset(); // $ExpectError + zlaset( 'row-major' ); // $ExpectError + zlaset( 'row-major', 'all' ); // $ExpectError + zlaset( 'row-major', 'all', 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2 ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, A ); // $ExpectError + zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, 2, 3 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Complex128Array... +{ + const A = new Complex128Array( 4 ); + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectType Complex128Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Complex128Array( 4 ); + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset.ndarray( 5, 2, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( true, 2, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( false, 2, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( null, 2, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( void 0, 2, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( [], 2, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( {}, 2, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( ( x: number ): number => x, 2, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const A = new Complex128Array( 4 ); + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset.ndarray( 'all', '5', 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', true, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', false, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', null, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', void 0, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', [], 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', {}, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', ( x: number ): number => x, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Complex128Array( 4 ); + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset.ndarray( 'all', 2, '5', alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, true, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, false, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, null, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, void 0, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, [], alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, {}, alpha, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, ( x: number ): number => x, alpha, beta, A, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Complex128... +{ + const A = new Complex128Array( 4 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset.ndarray( 'all', 2, 2, '5', beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, 5, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, true, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, false, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, null, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, void 0, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, [], beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, {}, beta, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, ( x: number ): number => x, beta, A, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Complex128... +{ + const A = new Complex128Array( 4 ); + const alpha = new Complex128( 3.0, 4.0 ); + + zlaset.ndarray( 'all', 2, 2, alpha, '5', A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, 5, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, true, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, false, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, null, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, void 0, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, [], A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, {}, A, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, ( x: number ): number => x, A, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Complex128Array... +{ + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset.ndarray( 'all', 2, 2, alpha, beta, '5', 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, 5, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, true, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, false, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, null, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, void 0, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, [], 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, {}, 2, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, ( x: number ): number => x, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const A = new Complex128Array( 4 ); + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, '5', 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, true, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, false, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, null, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, void 0, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, [], 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, {}, 1, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eighth argument which is not a number... +{ + const A = new Complex128Array( 4 ); + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, '5', 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, true, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, false, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, null, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, void 0, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, [], 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, {}, 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, ( 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 Complex128Array( 4 ); + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, '5' ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, true ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, false ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, null ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, void 0 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, [] ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, {} ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const A = new Complex128Array( 4 ); + const alpha = new Complex128( 1.0, 2.0 ); + const beta = new Complex128( 3.0, 4.0 ); + + zlaset.ndarray(); // $ExpectError + zlaset.ndarray( 'all' ); // $ExpectError + zlaset.ndarray( 'all', 2 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1 ); // $ExpectError + zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, 0, 3 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/examples/index.js b/lib/node_modules/@stdlib/lapack/base/zlaset/examples/index.js new file mode 100644 index 000000000000..64699f09a545 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/examples/index.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var zlaset = require( './../lib' ); + +var shape = [ 5, 8 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +var N = numel( shape ); + +var A = new Complex128Array( N ); +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var alpha = new Complex128( 1.0, 2.0 ); +console.log(alpha); + +var beta = new Complex128( 3.0, 4.0 ); +console.log(beta); + +zlaset( order, 'all', shape[ 0 ], shape[ 1 ], alpha, beta, A, strides[ 0 ] ); +console.log( ndarray2array( A, shape, strides, 0, order ) ); diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/base.js b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/base.js new file mode 100644 index 000000000000..067e250cd30d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/base.js @@ -0,0 +1,783 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var min = require( '@stdlib/math/base/special/fast/min' ); + + +// FUNCTIONS // + +/** +* Initializes all elements of matrix `A` to given values. +* +* @private +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Complex128} alpha - value assigned to off-diagonal elements +* @param {Complex128} beta - value assigned to diagonal elements +* @param {Complex128Array} 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 {Complex128Array} `A` +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* setAll( 2, 2, alpha, beta, A, 2, 1, 0 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setAll( 2, 2, alpha, beta, A, 2, -1, 1 ); +* +* var z = A.get( 0 ); +* +* real( z ) +* // => 1.0 +* +* imag( z ) +* // => 2.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* setAll( 2, 2, alpha, beta, A, -2, 1, 2 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 1.0 +* +* imag( z ) +* // => 2.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* setAll( 2, 2, alpha, beta, A, -2, -1, 3 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setAll( 2, 2, alpha, beta, A, 1, 2, 0 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* setAll( 2, 2, alpha, beta, A, -1, 2, 1 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 1.0 +* +* imag( z ) +* // => 2.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* setAll( 2, 2, alpha, beta, A, 1, -2, 2 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 1.0 +* +* imag( z ) +* // => 2.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* setAll( 2, 2, alpha, beta, A, -1, -2, 3 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +*/ +function setAll( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { + var alphar; + var alphai; + var betar; + var betai; + var viewA; + var da0; + var da1; + var sh; + var S0; + var S1; + var sa; + var ia; + var i0; + var i1; + var o; + + alphar = real( alpha ); + alphai = imag( alpha ); + betar = real( beta ); + betai = imag( beta ); + + // Resolve the loop interchange order: + o = loopOrder( [ M, N ], [ strideA1, strideA2 ] ); + sh = o.sh; + sa = o.sx; + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + + // Premultiply float64 strides by 2 + da0 = sa[ 0 ]*2; + da1 = (sa[ 1 ] - ( S0*sa[0] )) * 2; + + viewA = reinterpret( A, 0 ); + + // Set the pointers to the first indexed elements in the respective matrices... + ia = offsetA * 2; + + // Iterate over the matrix dimensions... + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( i0 === i1 ) { + viewA[ ia ] = betar; + viewA[ ia+1 ] = betai; + } else { + viewA[ ia ] = alphar; + viewA[ ia+1 ] = alphai; + } + ia += da0; + } + ia += da1; + } + return A; +} + +/** +* Initializes the upper triangular/trapezoidal part of a matrix `A` to given values. +* +* @private +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Complex128} alpha - value assigned to off-diagonal elements +* @param {Complex128} beta - value assigned to diagonal elements +* @param {Complex128Array} 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 {Complex128Array} `A` +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setUpper( 2, 2, alpha, beta, A, 2, 1, 0 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setUpper( 2, 2, alpha, beta, A, 2, -1, 1 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 1.0 +* +* imag( z ) +* // => 2.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setUpper( 2, 2, alpha, beta, A, -2, 1, 2 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 0.0 +* +* imag( z ) +* // => 0.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setUpper( 2, 2, alpha, beta, A, -2, -1, 3 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setUpper( 2, 2, alpha, beta, A, 1, 2, 0 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setUpper( 2, 2, alpha, beta, A, -1, 2, 1 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 0.0 +* +* imag( z ) +* // => 0.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setUpper( 2, 2, alpha, beta, A, 1, -2, 2 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 1.0 +* +* imag( z ) +* // => 2.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setUpper( 2, 2, alpha, beta, A, -1, -2, 3 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +*/ +function setUpper( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { + var alphar; + var alphai; + var betar; + var betai; + var viewA; + var idx; + var sa1; + var sa2; + var ia; + var i0; + var i1; + + alphar = real( alpha ); + alphai = imag( alpha ); + betar = real( beta ); + betai = imag( beta ); + + viewA = reinterpret( A, 0 ); + + // Premultiply float64 strides by 2 + ia = offsetA * 2; + sa1 = strideA1 * 2; + sa2 = strideA2 * 2; + + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for ( i1 = 0; i1 < M; i1++ ) { + for ( i0 = i1; i0 < N; i0++ ) { + idx = ia+(i0*sa2); + if ( i0 === i1 ) { + viewA[ idx ] = betar; + viewA[ idx+1 ] = betai; + } else { + viewA[ idx ] = alphar; + viewA[ idx+1 ] = alphai; + } + } + ia += sa1; + } + return A; + } + for ( i1 = 0; i1 < N; i1++ ) { + for ( i0 = 0; i0 <= min( i1, M-1 ); i0++ ) { + idx = ia+(i0*sa1); + if ( i0 === i1 ) { + viewA[ idx ] = betar; + viewA[ idx+1 ] = betai; + } else { + viewA[ idx ] = alphar; + viewA[ idx+1 ] = alphai; + } + } + ia += sa2; + } + return A; +} + +/** +* Initializes the lower triangular/trapezoidal part of a matrix `A` to given values. +* +* @private +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Complex128} alpha - value assigned to off-diagonal elements +* @param {Complex128} beta - value assigned to diagonal elements +* @param {Complex128Array} 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 {Complex128Array} `A` +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setLower( 2, 2, alpha, beta, A, 2, 1, 0 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 3.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setLower( 2, 2, alpha, beta, A, 2, -1, 1 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 0.0 +* +* imag( z ) +* // => 0.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setLower( 2, 2, alpha, beta, A, -2, 1, 2 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 1.0 +* +* imag( z ) +* // => 2.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setLower( 2, 2, alpha, beta, A, -2, -1, 3 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setLower( 2, 2, alpha, beta, A, 1, 2, 0 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setLower( 2, 2, alpha, beta, A, -1, 2, 1 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 1.0 +* +* imag( z ) +* // => 2.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setLower( 2, 2, alpha, beta, A, 1, -2, 2 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 0.0 +* +* imag( z ) +* // => 0.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* setLower( 2, 2, alpha, beta, A, -1, -2, 3 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +*/ +function setLower( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { + var alphar; + var alphai; + var betar; + var betai; + var viewA; + var sa1; + var sa2; + var idx; + var ia; + var i0; + var i1; + + alphar = real( alpha ); + alphai = imag( alpha ); + betar = real( beta ); + betai = imag( beta ); + + viewA = reinterpret( A, 0 ); + + // Premultiply float64 strides by 2 + ia = offsetA * 2; + sa1 = strideA1 * 2; + sa2 = strideA2 * 2; + + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for ( i1 = 0; i1 < M; i1++ ) { + for ( i0 = 0; i0 <= min( i1, N-1 ); i0++ ) { + idx = ia+(i0*sa2); + if ( i0 === i1 ) { + viewA[ idx ] = betar; + viewA[ idx+1 ] = betai; + } else { + viewA[ idx ] = alphar; + viewA[ idx+1 ] = alphai; + } + } + ia += sa1; + } + return A; + } + for ( i1 = 0; i1 < N; i1++ ) { + for ( i0 = i1; i0 < M; i0++ ) { + idx = ia+(i0*sa1); + if ( i0 === i1 ) { + viewA[ idx ] = betar; + viewA[ idx+1 ] = betai; + } else { + viewA[ idx ] = alphar; + viewA[ idx+1 ] = alphai; + } + } + ia += sa2; + } + return A; +} + + +// MAIN // + +/** +* Initializes elements of matrix `A` to given values. +* +* @private +* @param {string} uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Complex128} alpha - value assigned to off-diagonal elements +* @param {Complex128} beta - value assigned to diagonal elements +* @param {Complex128Array} 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 {Complex128Array} `A` +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* zlaset( 'all', 2, 2, alpha, beta, A, 2, 1, 0 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* zlaset( 'upper', 2, 2, alpha, beta, A, 2, 1, 0 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* zlaset( 'lower', 2, 2, alpha, beta, A, 2, 1, 0 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +*/ +function zlaset( 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 = zlaset; diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js new file mode 100644 index 000000000000..eae557b0690e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js @@ -0,0 +1,90 @@ +/** +* @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 the off-diagonal elements and the diagonal elements of a matrix to given values. +* +* @module @stdlib/lapack/base/zlaset +* +* @example +* var Complex128Array = require( '@stdlib/array/float64' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* var zlaset = require( '@stdlib/lapack/base/zlaset' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, 2 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/float64' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* var zlaset = require( '@stdlib/lapack/base/zlaset' ); +* +* var A = new Complex128Array( 5 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, 1 ); +* var z = A.get( 1 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var zlaset; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + zlaset = main; +} else { + zlaset = tmp; +} + + +// EXPORTS // + +module.exports = zlaset; + +// exports: { "ndarray": "zlaset.ndarray" } diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/main.js b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/main.js new file mode 100644 index 000000000000..75aecdd63b25 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 zlaset = require( './zlaset.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( zlaset, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = zlaset; diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/ndarray.js new file mode 100644 index 000000000000..12477227f2a1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/ndarray.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 base = require( './base.js' ); + + +// MAIN // + +/** +* Initializes the off-diagonal elements and the diagonal elements of a matrix to given values. +* +* @param {string} uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Complex128} alpha - value assigned to off-diagonal elements +* @param {Complex128} beta - value assigned to diagonal elements +* @param {Complex128Array} 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 {Complex128Array} `A` +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 5 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* zlaset( 'all', 2, 2, alpha, beta, A, 2, 1, 1 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 5 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* zlaset( 'upper', 2, 2, alpha, beta, A, 2, 1, 1 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* +* var A = new Complex128Array( 5 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* zlaset( 'lower', 2, 2, alpha, beta, A, 2, 1, 1 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +*/ +function zlaset( uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { + return base( uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ); +} + + +// EXPORTS // + +module.exports = zlaset; diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/zlaset.js b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/zlaset.js new file mode 100644 index 000000000000..71cadcea258a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/zlaset.js @@ -0,0 +1,125 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 // + +/** +* Initialize the off-diagonal elements and the diagonal elements of a matrix to given values. +* +* @param {string} order - storage layout of `A` +* @param {string} uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Complex128} alpha - value assigned to off-diagonal elements +* @param {Complex128} beta - value assigned to diagonal elements +* @param {Complex128Array} 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 +* @throws {RangeError} sixth argument must be greater than or equal to `N` +* @throws {RangeError} eighth argument must be greater than or equal to `N` +* @returns {Complex128Array} `A` +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, 2 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* zlaset( 'row-major', 'upper', 2, 2, alpha, beta, A, 2 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var real = require( '@stdlib/complex/float64/real' ); +* var imag = require( '@stdlib/complex/float64/imag' ); +* +* var A = new Complex128Array( 4 ); +* var alpha = new Complex128( 1.0, 2.0 ); +* var beta = new Complex128( 3.0, 4.0 ); +* +* zlaset( 'row-major', 'lower', 2, 2, alpha, beta, A, 2 ); +* var z = A.get( 0 ); +* +* real( z ) +* // => 3.0 +* +* imag( z ) +* // => 4.0 +*/ +function zlaset( 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 ) ); + } + if ( order === 'column-major' ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + if ( LDA < N ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to %d. Value: `%d`.', N, LDA ) ); + } + sa1 = LDA; + sa2 = 1; + } + return base( uplo, M, N, alpha, beta, A, sa1, sa2, 0 ); +} + + +// EXPORTS // + +module.exports = zlaset; diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/package.json b/lib/node_modules/@stdlib/lapack/base/zlaset/package.json new file mode 100644 index 000000000000..f26f715c3178 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/lapack/base/dlacpy", + "version": "0.0.0", + "description": "Initialize the off-diagonal elements and the diagonal elements of a matrix to given values.", + "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", + "dlacpy", + "copy", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "matrix", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.js b/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.js new file mode 100644 index 000000000000..b0dd34a7cda6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 zlaset = 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 zlaset, '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 zlaset.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 zlaset = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( zlaset, 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 zlaset; + var main; + + main = require( './../lib/zlaset.js' ); + + zlaset = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( zlaset, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.ndarray.js new file mode 100644 index 000000000000..a3132562c5ad --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.ndarray.js @@ -0,0 +1,532 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var zlaset = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zlaset, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', function test( t ) { + t.strictEqual( zlaset.length, 9, 'returns expected value' ); + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (row-major)', function test( t ) { + var expected; + var alpha; + var viewE; + var viewA; + var beta; + var out; + var M; + var N; + var A; + + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + M = 2; + N = 3; + + A = new Complex128Array( ( M*N ) + 1 ); + expected = new Complex128Array([ + 0.0, + 0.0, + 3.0, + 4.0, + 1.0, + 2.0, + 1.0, + 2.0, + 1.0, + 2.0, + 3.0, + 4.0, + 1.0, + 2.0 + ]); + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'all', 2, 3, alpha, beta, A, 3, 1, 1 ); + + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + A = new Complex128Array( ( M*N ) + 1); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 0.0, 0.0, + 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, + 1.0, 2.0, 1.0, 2.0, 3.0, 4.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'all', 2, 3, alpha, beta, A, -3, -1, 6 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + A = new Complex128Array( ( M*N ) + 1 ); + expected = new Complex128Array([ + 0.0, + 0.0, + 3.0, + 4.0, + 1.0, + 2.0, + 1.0, + 2.0, + 3.0, + 4.0, + 1.0, + 2.0, + 1.0, + 2.0 + ]); + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'all', 3, 2, alpha, beta, A, 2, 1, 1 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (row-major, upper)', function test( t ) { + var expected; + var alpha; + var viewE; + var viewA; + var beta; + var out; + var M; + var N; + var A; + + M = 3; + N = 2; + + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + A = new Complex128Array( ( M * N ) + 1 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 0.0, 0.0, + 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, + 0.0, 0.0, 3.0, 4.0, 1.0, 2.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'upper', 2, 3, alpha, beta, A, 3, 1, 1 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + A = new Complex128Array( ( M*N ) + 1 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 0.0, 0.0, + 1.0, 2.0, 1.0, 2.0, 3.0, 4.0, + 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'upper', 2, 3, alpha, beta, A, 3, -1, 3 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + A = new Complex128Array( ( M*N ) + 1 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 0.0, 0.0, + 3.0, 4.0, 1.0, 2.0, + 0.0, 0.0, 3.0, 4.0, + 0.0, 0.0, 0.0, 0.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'upper', 3, 2, alpha, beta, A, 2, 1, 1 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (row-major, lower)', function test( t ) { + var expected; + var viewA; + var viewE; + var alpha; + var beta; + var out; + var A; + var M; + var N; + + M = 3; + N = 2; + + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + A = new Complex128Array( ( M*N ) + 1 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 0.0, 0.0, + 3.0, 4.0, 0.0, 0.0, 0.0, 0.0, + 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'lower', 2, 3, alpha, beta, A, 3, 1, 1 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + A = new Complex128Array( ( M*N ) + 1 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 0.0, 0.0, + 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, + 3.0, 4.0, 0.0, 0.0, 0.0, 0.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'lower', 2, 3, alpha, beta, A, -3, 1, 4 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + A = new Complex128Array( ( M*N ) + 1 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 0.0, 0.0, + 3.0, 4.0, 0.0, 0.0, + 1.0, 2.0, 3.0, 4.0, + 1.0, 2.0, 1.0, 2.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'lower', 3, 2, alpha, beta, A, 2, 1, 1 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (column-major)', function test( t ) { + var expected; + var viewA; + var viewE; + var alpha; + var beta; + var out; + var A; + var M; + var N; + + M = 3; + N = 2; + + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + A = new Complex128Array( ( M*N ) + 1 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 0.0, 0.0, + 3.0, 4.0, 1.0, 2.0, + 1.0, 2.0, 3.0, 4.0, + 1.0, 2.0, 1.0, 2.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'all', 2, 3, alpha, beta, A, 1, 2, 1 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + A = new Complex128Array( ( M*N ) + 1 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 0.0, 0.0, + 3.0, 4.0, 1.0, 2.0, + 1.0, 2.0, 3.0, 4.0, + 1.0, 2.0, 1.0, 2.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'all', 2, 3, alpha, beta, A, 1, 2, 1 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + A = new Complex128Array( ( M*N ) + 1 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 0.0, 0.0, + 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, + 1.0, 2.0, 3.0, 4.0, 1.0, 2.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'all', 3, 2, alpha, beta, A, 1, 3, 1 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (column-major, upper)', function test( t ) { + var expected; + var viewA; + var viewE; + var alpha; + var beta; + var out; + var A; + var M; + var N; + + M = 3; + N = 2; + + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + A = new Complex128Array( ( M*N ) + 1 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 0.0, 0.0, + 3.0, 4.0, 0.0, 0.0, + 1.0, 2.0, 3.0, 4.0, + 1.0, 2.0, 1.0, 2.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'upper', 2, 3, alpha, beta, A, 1, 2, 1 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + A = new Complex128Array( ( M*N ) + 1 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 0.0, 0.0, + 3.0, 4.0, 0.0, 0.0, + 1.0, 2.0, 3.0, 4.0, + 1.0, 2.0, 1.0, 2.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'upper', 2, 3, alpha, beta, A, 1, 2, 1 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + A = new Complex128Array( ( M*N ) + 1 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 0.0, 0.0, + 3.0, 4.0, 0.0, 0.0, 0.0, 0.0, + 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'upper', 3, 2, alpha, beta, A, 1, 3, 1 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (column-major, lower)', function test( t ) { + var expected; + var viewA; + var viewE; + var alpha; + var beta; + var out; + var A; + var M; + var N; + + M = 3; + N = 2; + + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + A = new Complex128Array( ( M*N ) + 1 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 0.0, 0.0, + 3.0, 4.0, 1.0, 2.0, + 0.0, 0.0, 3.0, 4.0, + 0.0, 0.0, 0.0, 0.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'lower', 2, 3, alpha, beta, A, 1, 2, 1 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + A = new Complex128Array( ( M*N ) + 1 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 0.0, 0.0, + 3.0, 4.0, 1.0, 2.0, + 0.0, 0.0, 3.0, 4.0, + 0.0, 0.0, 0.0, 0.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'lower', 2, 3, alpha, beta, A, 1, 2, 1 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + A = new Complex128Array( ( M*N ) + 1 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 0.0, 0.0, + 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, + 0.0, 0.0, 3.0, 4.0, 1.0, 2.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'lower', 3, 2, alpha, beta, A, 1, 3, 1 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (column-major, lower, complex access patterns)', function test( t ) { + var expected; + var viewA; + var viewE; + var alpha; + var beta; + var out; + var A; + + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + /* eslint-disable array-element-newline, no-multi-spaces */ + + A = new Complex128Array([ + 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, + 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, + 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, + 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, + 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999 + ]); + + expected = new Complex128Array([ + 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, + 999, 999, 3, 4, 999, 999, 1, 2, 999, 999, 1, 2, + 999, 999, 1, 2, 999, 999, 3, 4, 999, 999, 1, 2, + 999, 999, 1, 2, 999, 999, 1, 2, 999, 999, 3, 4, + 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999 + ]); + + /* eslint-enable array-element-newline, no-multi-spaces */ + + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'all', 3, 3, alpha, beta, A, 2, 6, 7 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.zlaset.js b/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.zlaset.js new file mode 100644 index 000000000000..c0c6f6fd37b5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.zlaset.js @@ -0,0 +1,346 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var zlaset = require( './../lib/zlaset.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zlaset, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( zlaset.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 alpha; + var beta; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + A = new Complex128Array( 4 ); + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 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() { + zlaset( value, 'all', 2, 2, alpha, beta, A, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid sixth argument (row-major)', function test( t ) { + var values; + var alpha; + var beta; + var A; + var i; + + values = [ + 0, + 1 + ]; + + A = new Complex128Array( 4 ); + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid eighth argument (row-major)', function test( t ) { + var values; + var alpha; + var beta; + var A; + var i; + + values = [ + 0, + 1 + ]; + + A = new Complex128Array( 4 ); + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, value ); + }; + } +}); + +tape( 'the function assigns values to matrix `A` (row-major)', function test( t ) { + var expected; + var viewA; + var viewE; + var alpha; + var beta; + var out; + var A; + var M; + var N; + + M = 3; + N = 4; + + A = new Complex128Array( M*N ); + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, 1.0, 2.0, + 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, + 1.0, 2.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'row-major', 'all', M, N, alpha, beta, A, N ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (row-major, upper)', function test( t ) { + var expected; + var viewA; + var viewE; + var alpha; + var beta; + var out; + var A; + var M; + var N; + + M = 3; + N = 4; + + A = new Complex128Array( M*N ); + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, 1.0, 2.0, + 0.0, 0.0, 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, + 0.0, 0.0, 0.0, 0.0, 3.0, 4.0, 1.0, 2.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'row-major', 'upper', M, N, alpha, beta, A, N ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (row-major, lower)', function test( t ) { + var expected; + var viewA; + var viewE; + var alpha; + var beta; + var out; + var A; + var M; + var N; + + M = 3; + N = 4; + + A = new Complex128Array( M*N ); + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 3.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 0.0, 0.0, + 1.0, 2.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'row-major', 'lower', M, N, alpha, beta, A, N ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (column-major)', function test( t ) { + var expected; + var viewA; + var viewE; + var alpha; + var beta; + var out; + var A; + var M; + var N; + + M = 3; + N = 4; + + A = new Complex128Array( M*N ); + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, + 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, + 1.0, 2.0, 1.0, 2.0, 3.0, 4.0, + 1.0, 2.0, 1.0, 2.0, 1.0, 2.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'column-major', 'all', M, N, alpha, beta, A, M ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (column-major, upper)', function test( t ) { + var expected; + var viewA; + var viewE; + var alpha; + var beta; + var out; + var A; + var M; + var N; + + M = 3; + N = 4; + + A = new Complex128Array( M*N ); + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 3.0, 4.0, 0.0, 0.0, 0.0, 0.0, + 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, + 1.0, 2.0, 1.0, 2.0, 3.0, 4.0, + 1.0, 2.0, 1.0, 2.0, 1.0, 2.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'column-major', 'upper', M, N, alpha, beta, A, M ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (column-major, lower)', function test( t ) { + var expected; + var viewA; + var viewE; + var alpha; + var beta; + var out; + var A; + var M; + var N; + + M = 3; + N = 4; + + A = new Complex128Array( M*N ); + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, + 0.0, 0.0, 3.0, 4.0, 1.0, 2.0, + 0.0, 0.0, 0.0, 0.0, 3.0, 4.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 + ]); + + /* eslint-enable array-element-newline */ + viewE = reinterpret( expected, 0 ); + viewA = reinterpret( A, 0 ); + + out = zlaset( 'column-major', 'lower', M, N, alpha, beta, A, M ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( viewA, viewE, 'returns expected value' ); + + t.end(); +}); From ab02c922e341a365a96a9842ac96c42584a43834 Mon Sep 17 00:00:00 2001 From: Ricky Reusser <572717+rreusser@users.noreply.github.com> Date: Fri, 17 Jan 2025 10:52:35 -0800 Subject: [PATCH 2/7] perf: move math ops out of zlaset inner loop --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/zlaset/lib/base.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/base.js b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/base.js index 067e250cd30d..af523df922d6 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/base.js @@ -439,8 +439,8 @@ function setUpper( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { if ( isRowMajor( [ strideA1, strideA2 ] ) ) { for ( i1 = 0; i1 < M; i1++ ) { + idx = ia+(i1*sa2); for ( i0 = i1; i0 < N; i0++ ) { - idx = ia+(i0*sa2); if ( i0 === i1 ) { viewA[ idx ] = betar; viewA[ idx+1 ] = betai; @@ -448,14 +448,15 @@ function setUpper( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { viewA[ idx ] = alphar; viewA[ idx+1 ] = alphai; } + idx += sa2; } ia += sa1; } return A; } for ( i1 = 0; i1 < N; i1++ ) { + idx = ia; for ( i0 = 0; i0 <= min( i1, M-1 ); i0++ ) { - idx = ia+(i0*sa1); if ( i0 === i1 ) { viewA[ idx ] = betar; viewA[ idx+1 ] = betai; @@ -463,6 +464,7 @@ function setUpper( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { viewA[ idx ] = alphar; viewA[ idx+1 ] = alphai; } + idx += sa1; } ia += sa2; } @@ -662,8 +664,8 @@ function setLower( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { if ( isRowMajor( [ strideA1, strideA2 ] ) ) { for ( i1 = 0; i1 < M; i1++ ) { + idx = ia; for ( i0 = 0; i0 <= min( i1, N-1 ); i0++ ) { - idx = ia+(i0*sa2); if ( i0 === i1 ) { viewA[ idx ] = betar; viewA[ idx+1 ] = betai; @@ -671,14 +673,15 @@ function setLower( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { viewA[ idx ] = alphar; viewA[ idx+1 ] = alphai; } + idx += sa2; } ia += sa1; } return A; } for ( i1 = 0; i1 < N; i1++ ) { + idx = ia+(i1*sa1); for ( i0 = i1; i0 < M; i0++ ) { - idx = ia+(i0*sa1); if ( i0 === i1 ) { viewA[ idx ] = betar; viewA[ idx+1 ] = betai; @@ -686,6 +689,7 @@ function setLower( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { viewA[ idx ] = alphar; viewA[ idx+1 ] = alphai; } + idx += sa1; } ia += sa2; } From 60fc65ae9d8d4e19bc53e4b5d7256c1265534aec Mon Sep 17 00:00:00 2001 From: Ricky Reusser <572717+rreusser@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:07:38 -0800 Subject: [PATCH 3/7] chore: fix copyright years and missing import --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/lapack/base/zlaset/README.md | 1 + lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/test.ts | 2 +- lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/README.md b/lib/node_modules/@stdlib/lapack/base/zlaset/README.md index 2a6ff07a2bcb..0e9103d32a17 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/README.md +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/README.md @@ -188,6 +188,7 @@ var Complex128 = require( '@stdlib/complex/float64/ctor' ); var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); var numel = require( '@stdlib/ndarray/base/numel' ); var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var zlaset = require( '@stdlib/lapack/base/zlaset' ); var shape = [ 5, 8 ]; var order = 'row-major'; diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/test.ts index 3d8b7ff68a86..303841bad361 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/test.ts +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js index eae557b0690e..ae3f42537227 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 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. From 442414fbd5b03881bfe20d81eb89237815788310 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sun, 19 Jan 2025 02:20:20 -0800 Subject: [PATCH 4/7] refactor: remove branching within internal loops and remove duplicated logic --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../@stdlib/lapack/base/zlaset/lib/base.js | 815 +++++++----------- .../@stdlib/lapack/base/zlaset/lib/index.js | 22 +- .../@stdlib/lapack/base/zlaset/lib/ndarray.js | 97 ++- .../@stdlib/lapack/base/zlaset/lib/zlaset.js | 92 +- 4 files changed, 499 insertions(+), 527 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/base.js b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/base.js index af523df922d6..9c137d5cf9b5 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/base.js @@ -31,170 +31,147 @@ var min = require( '@stdlib/math/base/special/fast/min' ); // FUNCTIONS // /** -* Initializes all elements of matrix `A` to given values. +* Sets the diagonal of a matrix `A` to a specified value. * * @private * @param {NonNegativeInteger} M - number of rows in matrix `A` * @param {NonNegativeInteger} N - number of columns in matrix `A` -* @param {Complex128} alpha - value assigned to off-diagonal elements -* @param {Complex128} beta - value assigned to diagonal elements -* @param {Complex128Array} A - input matrix +* @param {number} breal - real component of the value to assign to diagonal elements +* @param {number} bimag - imaginary component of the value to assign to diagonal elements +* @param {Float64Array} A - input matrix view * @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 {Complex128Array} `A` +* @returns {Float64Array} `A` * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var A = new Complex128Array( 4 ); -* setAll( 2, 2, alpha, beta, A, 2, 1, 0 ); -* var z = A.get( 0 ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* real( z ) -* // => 3.0 +* var 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 ] ); * -* imag( z ) -* // => 4.0 +* setDiagonal( 2, 3, 1.0, 2.0, A, 6, 2, 0 ); +* // A => [ 1.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 0.0, 0.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); +* var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); * -* setAll( 2, 2, alpha, beta, A, 2, -1, 1 ); +* setDiagonal( 2, 2, 1.0, 2.0, A, 4, 2, 0 ); +* // A => [ 1.0, 2.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0 ] * -* var z = A.get( 0 ); +* @example +* var Float64Array = require( '@stdlib/array/float64' ); * -* real( z ) -* // => 1.0 +* var 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 ] ); * -* imag( z ) -* // => 2.0 +* setDiagonal( 3, 2, 1.0, 2.0, A, 4, 2, 0 ); +* // A => [ 1.0, 2.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 0.0, 0.0, 0.0, 0.0 ] +*/ +function setDiagonal( M, N, breal, bimag, 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 ] = breal; + A[ ia+1 ] = bimag; + ia += sa; + } + return A; +} + +/** +* Sets all elements of a matrix `A` to specified values. * -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); +* @private +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {number} areal - real component of the value to assign to off-diagonal elements +* @param {number} aimag - imaginary component of the value to assign to off-diagonal elements +* @param {number} breal - real component of the value to assign to diagonal elements +* @param {number} bimag - imaginary component of the value to assign to diagonal elements +* @param {Float64Array} A - input matrix view +* @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` * -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); -* setAll( 2, 2, alpha, beta, A, -2, 1, 2 ); -* var z = A.get( 0 ); +* @example +* var Float64Array = require( '@stdlib/array/float64' ); * -* real( z ) -* // => 1.0 +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* imag( z ) -* // => 2.0 +* setAll( 2, 2, 1.0, 2.0, 3.0, 4.0, A, 4, 2, 0 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, 3.0, 4.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); -* setAll( 2, 2, alpha, beta, A, -2, -1, 3 ); -* var z = A.get( 0 ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* real( z ) -* // => 3.0 +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* imag( z ) -* // => 4.0 +* setAll( 2, 2, 1.0, 2.0, 3.0, 4.0, A, 4, -2, 2 ); +* // A => [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 1.0, 2.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* setAll( 2, 2, alpha, beta, A, 1, 2, 0 ); -* var z = A.get( 0 ); +* setAll( 2, 2, 1.0, 2.0, 3.0, 4.0, A, -4, 2, 4 ); +* // A => [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 1.0, 2.0 ] * -* real( z ) -* // => 3.0 +* @example +* var Float64Array = require( '@stdlib/array/float64' ); * -* imag( z ) -* // => 4.0 +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); +* setAll( 2, 2, 1.0, 2.0, 3.0, 4.0, A, -4, -2, 6 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, 3.0, 4.0 ] * -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); -* setAll( 2, 2, alpha, beta, A, -1, 2, 1 ); -* var z = A.get( 0 ); +* @example +* var Float64Array = require( '@stdlib/array/float64' ); * -* real( z ) -* // => 1.0 +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* imag( z ) -* // => 2.0 +* setAll( 2, 2, 1.0, 2.0, 3.0, 4.0, A, 2, 4, 0 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, 3.0, 4.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); -* setAll( 2, 2, alpha, beta, A, 1, -2, 2 ); -* var z = A.get( 0 ); -* -* real( z ) -* // => 1.0 +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* imag( z ) -* // => 2.0 +* setAll( 2, 2, 1.0, 2.0, 3.0, 4.0, A, -2, 4, 2 ); +* // A => [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 1.0, 2.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); -* setAll( 2, 2, alpha, beta, A, -1, -2, 3 ); -* var z = A.get( 0 ); +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] +* +* setAll( 2, 2, 1.0, 2.0, 3.0, 4.0, A, 2, -4, 4 ); +* // A => [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 1.0, 2.0 ] * -* real( z ) -* // => 3.0 +* @example +* var Float64Array = require( '@stdlib/array/float64' ); * -* imag( z ) -* // => 4.0 +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] +* +* setAll( 2, 2, 1.0, 2.0, 3.0, 4.0, A, -2, -4, 6 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, 3.0, 4.0 ] */ -function setAll( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { - var alphar; - var alphai; - var betar; - var betai; - var viewA; +function setAll( M, N, areal, aimag, breal, bimag, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len var da0; var da1; var sh; @@ -206,11 +183,6 @@ function setAll( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { var i1; var o; - alphar = real( alpha ); - alphai = imag( alpha ); - betar = real( beta ); - betai = imag( beta ); - // Resolve the loop interchange order: o = loopOrder( [ M, N ], [ strideA1, strideA2 ] ); sh = o.sh; @@ -219,480 +191,266 @@ function setAll( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... S0 = sh[ 0 ]; S1 = sh[ 1 ]; + da0 = sa[ 0 ]; + da1 = sa[ 1 ] - ( S0*sa[0] ); - // Premultiply float64 strides by 2 - da0 = sa[ 0 ]*2; - da1 = (sa[ 1 ] - ( S0*sa[0] )) * 2; - - viewA = reinterpret( A, 0 ); + // Set the pointer to the first indexed element: + ia = offsetA; - // Set the pointers to the first indexed elements in the respective matrices... - ia = offsetA * 2; - - // Iterate over the matrix dimensions... + // Fill the array with a scalar value... for ( i1 = 0; i1 < S1; i1++ ) { for ( i0 = 0; i0 < S0; i0++ ) { - if ( i0 === i1 ) { - viewA[ ia ] = betar; - viewA[ ia+1 ] = betai; - } else { - viewA[ ia ] = alphar; - viewA[ ia+1 ] = alphai; - } + A[ ia ] = areal; + A[ ia+1 ] = aimag; ia += da0; } ia += da1; } + // Replace the diagonal: + setDiagonal( M, N, breal, bimag, A, strideA1, strideA2, offsetA ); + return A; } /** -* Initializes the upper triangular/trapezoidal part of a matrix `A` to given values. +* Sets the upper triangular/trapezoidal part of a matrix `A` to specified values. * * @private * @param {NonNegativeInteger} M - number of rows in matrix `A` * @param {NonNegativeInteger} N - number of columns in matrix `A` -* @param {Complex128} alpha - value assigned to off-diagonal elements -* @param {Complex128} beta - value assigned to diagonal elements -* @param {Complex128Array} A - input matrix +* @param {number} areal - real component of the value to assign to off-diagonal elements +* @param {number} aimag - imaginary component of the value to assign to off-diagonal elements +* @param {number} breal - real component of the value to assign to diagonal elements +* @param {number} bimag - imaginary component of the value to assign to diagonal elements +* @param {Float64Array} A - input matrix view * @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 {Complex128Array} `A` +* @returns {Float64Array} `A` * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); -* -* setUpper( 2, 2, alpha, beta, A, 2, 1, 0 ); -* var z = A.get( 0 ); -* -* real( z ) -* // => 3.0 +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* imag( z ) -* // => 4.0 +* setUpper( 2, 2, 1.0, 2.0, 3.0, 4.0, A, 4, 2, 0 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 0.0, 0.0, 3.0, 4.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); -* -* setUpper( 2, 2, alpha, beta, A, 2, -1, 1 ); -* var z = A.get( 0 ); +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* real( z ) -* // => 1.0 -* -* imag( z ) -* // => 2.0 +* setUpper( 2, 2, 1.0, 2.0, 3.0, 4.0, A, 4, -2, 2 ); +* // A => [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 0.0, 0.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); -* -* setUpper( 2, 2, alpha, beta, A, -2, 1, 2 ); -* var z = A.get( 0 ); +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* real( z ) -* // => 0.0 -* -* imag( z ) -* // => 0.0 +* setUpper( 2, 2, 1.0, 2.0, 3.0, 4.0, A, -4, 2, 4 ); +* // A => [ 0.0, 0.0, 3.0, 4.0, 3.0, 4.0, 1.0, 2.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); -* -* setUpper( 2, 2, alpha, beta, A, -2, -1, 3 ); -* var z = A.get( 0 ); +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* real( z ) -* // => 3.0 -* -* imag( z ) -* // => 4.0 +* setUpper( 2, 2, 1.0, 2.0, 3.0, 4.0, A, -4, -2, 6 ); +* // A => [ 3.0, 4.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); -* -* setUpper( 2, 2, alpha, beta, A, 1, 2, 0 ); -* var z = A.get( 0 ); +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* real( z ) -* // => 3.0 -* -* imag( z ) -* // => 4.0 +* setUpper( 2, 2, 1.0, 2.0, 3.0, 4.0, A, 2, 4, 0 ); +* // A => [ 3.0, 4.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* setUpper( 2, 2, alpha, beta, A, -1, 2, 1 ); -* var z = A.get( 0 ); -* -* real( z ) -* // => 0.0 +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* imag( z ) -* // => 0.0 +* setUpper( 2, 2, 1.0, 2.0, 3.0, 4.0, A, -2, 4, 2 ); +* // A => [ 0.0, 0.0, 3.0, 4.0, 3.0, 4.0, 1.0, 2.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* setUpper( 2, 2, alpha, beta, A, 1, -2, 2 ); -* var z = A.get( 0 ); -* -* real( z ) -* // => 1.0 +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* imag( z ) -* // => 2.0 +* setUpper( 2, 2, 1.0, 2.0, 3.0, 4.0, A, 2, -4, 4 ); +* // A => [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 0.0, 0.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* setUpper( 2, 2, alpha, beta, A, -1, -2, 3 ); -* var z = A.get( 0 ); -* -* real( z ) -* // => 3.0 +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* imag( z ) -* // => 4.0 +* setUpper( 2, 2, 1.0, 2.0, 3.0, 4.0, A, -2, -4, 6 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 0.0, 0.0, 3.0, 4.0 ] */ -function setUpper( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { - var alphar; - var alphai; - var betar; - var betai; - var viewA; +function setUpper( M, N, areal, aimag, breal, bimag, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len var idx; - var sa1; - var sa2; var ia; var i0; var i1; - alphar = real( alpha ); - alphai = imag( alpha ); - betar = real( beta ); - betai = imag( beta ); - - viewA = reinterpret( A, 0 ); - - // Premultiply float64 strides by 2 - ia = offsetA * 2; - sa1 = strideA1 * 2; - sa2 = strideA2 * 2; - + ia = offsetA; if ( isRowMajor( [ strideA1, strideA2 ] ) ) { for ( i1 = 0; i1 < M; i1++ ) { - idx = ia+(i1*sa2); + idx = ia + ( i1*strideA2 ); for ( i0 = i1; i0 < N; i0++ ) { - if ( i0 === i1 ) { - viewA[ idx ] = betar; - viewA[ idx+1 ] = betai; - } else { - viewA[ idx ] = alphar; - viewA[ idx+1 ] = alphai; - } - idx += sa2; + A[ idx ] = areal; + A[ idx+1 ] = aimag; + idx += strideA2; } - ia += sa1; + ia += strideA1; } + setDiagonal( M, N, breal, bimag, A, strideA1, strideA2, offsetA ); return A; } for ( i1 = 0; i1 < N; i1++ ) { idx = ia; for ( i0 = 0; i0 <= min( i1, M-1 ); i0++ ) { - if ( i0 === i1 ) { - viewA[ idx ] = betar; - viewA[ idx+1 ] = betai; - } else { - viewA[ idx ] = alphar; - viewA[ idx+1 ] = alphai; - } - idx += sa1; + A[ idx ] = areal; + A[ idx+1 ] = aimag; + idx += strideA1; } - ia += sa2; + ia += strideA2; } + setDiagonal( M, N, breal, bimag, A, strideA1, strideA2, offsetA ); return A; } /** -* Initializes the lower triangular/trapezoidal part of a matrix `A` to given values. +* Sets the lower triangular/trapezoidal part of a matrix `A` to specified values. * * @private * @param {NonNegativeInteger} M - number of rows in matrix `A` * @param {NonNegativeInteger} N - number of columns in matrix `A` -* @param {Complex128} alpha - value assigned to off-diagonal elements -* @param {Complex128} beta - value assigned to diagonal elements -* @param {Complex128Array} A - input matrix +* @param {number} areal - real component of the value to assign to off-diagonal elements +* @param {number} aimag - imaginary component of the value to assign to off-diagonal elements +* @param {number} breal - real component of the value to assign to diagonal elements +* @param {number} bimag - imaginary component of the value to assign to diagonal elements +* @param {Float64Array} A - input matrix view * @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 {Complex128Array} `A` +* @returns {Float64Array} `A` * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); -* -* setLower( 2, 2, alpha, beta, A, 2, 1, 0 ); -* var z = A.get( 0 ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* real( z ) -* // => 3.0 +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* imag( z ) -* // => 3.0 +* setLower( 2, 2, 1.0, 2.0, 3.0, 4.0, A, 4, 2, 0 ); +* // A => [ 3.0, 4.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); -* -* setLower( 2, 2, alpha, beta, A, 2, -1, 1 ); -* var z = A.get( 0 ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* real( z ) -* // => 0.0 +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* imag( z ) -* // => 0.0 +* setLower( 2, 2, 1.0, 2.0, 3.0, 4.0, A, 4, -2, 2 ); +* // A => [ 0.0, 0.0, 3.0, 4.0, 3.0, 4.0, 1.0, 2.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); -* -* setLower( 2, 2, alpha, beta, A, -2, 1, 2 ); -* var z = A.get( 0 ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* real( z ) -* // => 1.0 +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* imag( z ) -* // => 2.0 +* setLower( 2, 2, 1.0, 2.0, 3.0, 4.0, A, -4, 2, 4 ); +* // A => [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 0.0, 0.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* setLower( 2, 2, alpha, beta, A, -2, -1, 3 ); -* var z = A.get( 0 ); -* -* real( z ) -* // => 3.0 -* -* imag( z ) -* // => 4.0 +* setLower( 2, 2, 1.0, 2.0, 3.0, 4.0, A, -4, -2, 6 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 0.0, 0.0, 3.0, 4.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* setLower( 2, 2, alpha, beta, A, 1, 2, 0 ); -* var z = A.get( 0 ); +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* real( z ) -* // => 3.0 -* -* imag( z ) -* // => 4.0 +* setLower( 2, 2, 1.0, 2.0, 3.0, 4.0, A, 2, 4, 0 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 0.0, 0.0, 3.0, 4.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* setLower( 2, 2, alpha, beta, A, -1, 2, 1 ); -* var z = A.get( 0 ); +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* real( z ) -* // => 1.0 -* -* imag( z ) -* // => 2.0 +* setLower( 2, 2, 1.0, 2.0, 3.0, 4.0, A, -2, 4, 2 ); +* // A => [ 1.0, 2.0, 3.0, 4.0, 3.0, 4.0, 0.0, 0.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* setLower( 2, 2, alpha, beta, A, 1, -2, 2 ); -* var z = A.get( 0 ); +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* real( z ) -* // => 0.0 -* -* imag( z ) -* // => 0.0 +* setLower( 2, 2, 1.0, 2.0, 3.0, 4.0, A, 2, -4, 4 ); +* // A => [ 0.0, 0.0, 3.0, 4.0, 3.0, 4.0, 1.0, 2.0 ] * * @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var A = new Complex128Array( 4 ); -* var alpha = new Complex128( 1.0, 2.0 ); -* var beta = new Complex128( 3.0, 4.0 ); -* -* setLower( 2, 2, alpha, beta, A, -1, -2, 3 ); -* var z = A.get( 0 ); +* var Float64Array = require( '@stdlib/array/float64' ); * -* real( z ) -* // => 3.0 +* var A = new Float64Array( 8 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] * -* imag( z ) -* // => 4.0 +* setLower( 2, 2, 1.0, 2.0, 3.0, 4.0, A, -2, -4, 6 ); +* // A => [ 3.0, 4.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] */ -function setLower( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { - var alphar; - var alphai; - var betar; - var betai; - var viewA; - var sa1; - var sa2; +function setLower( M, N, areal, aimag, breal, bimag, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len var idx; var ia; var i0; var i1; - alphar = real( alpha ); - alphai = imag( alpha ); - betar = real( beta ); - betai = imag( beta ); - - viewA = reinterpret( A, 0 ); - - // Premultiply float64 strides by 2 - ia = offsetA * 2; - sa1 = strideA1 * 2; - sa2 = strideA2 * 2; - + ia = offsetA; if ( isRowMajor( [ strideA1, strideA2 ] ) ) { for ( i1 = 0; i1 < M; i1++ ) { idx = ia; for ( i0 = 0; i0 <= min( i1, N-1 ); i0++ ) { - if ( i0 === i1 ) { - viewA[ idx ] = betar; - viewA[ idx+1 ] = betai; - } else { - viewA[ idx ] = alphar; - viewA[ idx+1 ] = alphai; - } - idx += sa2; + A[ idx ] = areal; + A[ idx+1 ] = aimag; + idx += strideA2; } - ia += sa1; + ia += strideA1; } + setDiagonal( M, N, breal, bimag, A, strideA1, strideA2, offsetA ); return A; } for ( i1 = 0; i1 < N; i1++ ) { - idx = ia+(i1*sa1); + idx = ia + ( i1*strideA1 ); for ( i0 = i1; i0 < M; i0++ ) { - if ( i0 === i1 ) { - viewA[ idx ] = betar; - viewA[ idx+1 ] = betai; - } else { - viewA[ idx ] = alphar; - viewA[ idx+1 ] = alphai; - } - idx += sa1; + A[ idx ] = areal; + A[ idx+1 ] = aimag; + idx += strideA1; } - ia += sa2; + ia += strideA2; } + setDiagonal( M, N, breal, bimag, A, strideA1, strideA2, offsetA ); return A; } @@ -700,10 +458,10 @@ function setLower( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { // MAIN // /** -* Initializes elements of matrix `A` to given values. +* Sets elements of matrix `A` to specified values. * * @private -* @param {string} uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param {string} uplo - specifies whether to set the upper or lower triangular/trapezoidal part of matrix `A` * @param {NonNegativeInteger} M - number of rows in matrix `A` * @param {NonNegativeInteger} N - number of columns in matrix `A` * @param {Complex128} alpha - value assigned to off-diagonal elements @@ -721,17 +479,38 @@ function setLower( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { * var imag = require( '@stdlib/complex/float64/imag' ); * * var A = new Complex128Array( 4 ); +* * var alpha = new Complex128( 1.0, 2.0 ); * var beta = new Complex128( 3.0, 4.0 ); * * zlaset( 'all', 2, 2, alpha, beta, A, 2, 1, 0 ); +* * var z = A.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns 3.0 +* +* var im = imag( z ); +* // returns 4.0 * -* real( z ) -* // => 3.0 +* z = A.get( 1 ); +* // returns * -* imag( z ) -* // => 4.0 +* re = real( z ); +* // returns 1.0 +* +* im = imag( z ); +* // returns 2.0 +* +* z = A.get( 2 ); +* // returns +* +* re = real( z ); +* // returns 1.0 +* +* im = imag( z ); +* // returns 2.0 * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); @@ -740,17 +519,38 @@ function setLower( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { * var imag = require( '@stdlib/complex/float64/imag' ); * * var A = new Complex128Array( 4 ); +* * var alpha = new Complex128( 1.0, 2.0 ); * var beta = new Complex128( 3.0, 4.0 ); * * zlaset( 'upper', 2, 2, alpha, beta, A, 2, 1, 0 ); +* * var z = A.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns 3.0 +* +* var im = imag( z ); +* // returns 4.0 +* +* z = A.get( 1 ); +* // returns +* +* re = real( z ); +* // returns 1.0 * -* real( z ) -* // => 3.0 +* im = imag( z ); +* // returns 2.0 * -* imag( z ) -* // => 4.0 +* z = A.get( 2 ); +* // returns +* +* re = real( z ); +* // returns 0.0 +* +* im = imag( z ); +* // returns 0.0 * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); @@ -759,26 +559,69 @@ function setLower( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { * var imag = require( '@stdlib/complex/float64/imag' ); * * var A = new Complex128Array( 4 ); +* * var alpha = new Complex128( 1.0, 2.0 ); * var beta = new Complex128( 3.0, 4.0 ); * * zlaset( 'lower', 2, 2, alpha, beta, A, 2, 1, 0 ); +* * var z = A.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns 3.0 +* +* var im = imag( z ); +* // returns 4.0 +* +* z = A.get( 1 ); +* // returns +* +* re = real( z ); +* // returns 0.0 +* +* im = imag( z ); +* // returns 0.0 +* +* z = A.get( 2 ); +* // returns * -* real( z ) -* // => 3.0 +* re = real( z ); +* // returns 1.0 * -* imag( z ) -* // => 4.0 +* im = imag( z ); +* // returns 2.0 */ function zlaset( uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { + var viewA; + var ar; + var ai; + var br; + var bi; + + // Reinterpret the input array as a real-valued array of interleaved real and imaginary components: + viewA = reinterpret( A, 0 ); + + // Adjust the strides and offset accordingly: + strideA1 *= 2; + strideA2 *= 2; + + offsetA *= 2; + + // Decompose the scalars to real and imaginary components: + ar = real( alpha ); + ai = imag( alpha ); + br = real( beta ); + bi = imag( beta ); + if ( uplo === 'upper' ) { - return setUpper( M, N, alpha, beta, A, strideA1, strideA2, offsetA ); + setUpper( M, N, ar, ai, br, bi, viewA, strideA1, strideA2, offsetA ); + } else if ( uplo === 'lower' ) { + setLower( M, N, ar, ai, br, bi, viewA, strideA1, strideA2, offsetA ); + } else { + setAll( M, N, ar, ai, br, bi, viewA, 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 ); + return A; } diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js index ae3f42537227..5cd63c523fee 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* LAPACK routine to initialize the off-diagonal elements and the diagonal elements of a matrix to given values. +* LAPACK routine to set the off-diagonal elements and the diagonal elements of a matrix to specified values. * * @module @stdlib/lapack/base/zlaset * @@ -35,13 +35,15 @@ * var beta = new Complex128( 3.0, 4.0 ); * * zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, 2 ); +* * var z = A.get( 0 ); +* // returns * -* real( z ) -* // => 3.0 +* var re = real( z ); +* // returns 3.0 * -* imag( z ) -* // => 4.0 +* var im = imag( z ) +* // returns 4.0 * * @example * var Complex128Array = require( '@stdlib/array/float64' ); @@ -55,13 +57,15 @@ * var beta = new Complex128( 3.0, 4.0 ); * * zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, 1 ); +* * var z = A.get( 1 ); +* // returns * -* real( z ) -* // => 3.0 +* var re = real( z ); +* // returns 3.0 * -* imag( z ) -* // => 4.0 +* var im = imag( z ); +* // returns 4.0 */ // MODULES // diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/ndarray.js index 12477227f2a1..8e7880dbd625 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/ndarray.js @@ -26,9 +26,9 @@ var base = require( './base.js' ); // MAIN // /** -* Initializes the off-diagonal elements and the diagonal elements of a matrix to given values. +* Sets the off-diagonal elements and the diagonal elements of a matrix to specified values. * -* @param {string} uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param {string} uplo - specifies whether to set the upper or lower triangular/trapezoidal part of matrix `A` * @param {NonNegativeInteger} M - number of rows in matrix `A` * @param {NonNegativeInteger} N - number of columns in matrix `A` * @param {Complex128} alpha - value assigned to off-diagonal elements @@ -46,17 +46,38 @@ var base = require( './base.js' ); * var imag = require( '@stdlib/complex/float64/imag' ); * * var A = new Complex128Array( 5 ); +* * var alpha = new Complex128( 1.0, 2.0 ); * var beta = new Complex128( 3.0, 4.0 ); * * zlaset( 'all', 2, 2, alpha, beta, A, 2, 1, 1 ); -* var z = A.get( 0 ); * -* real( z ) -* // => 3.0 +* var z = A.get( 1 ); +* // returns +* +* var re = real( z ); +* // returns 3.0 +* +* var im = imag( z ); +* // returns 4.0 +* +* z = A.get( 2 ); +* // returns +* +* re = real( z ); +* // returns 1.0 +* +* im = imag( z ); +* // returns 2.0 * -* imag( z ) -* // => 4.0 +* z = A.get( 3 ); +* // returns +* +* re = real( z ); +* // returns 1.0 +* +* im = imag( z ); +* // returns 2.0 * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); @@ -65,34 +86,76 @@ var base = require( './base.js' ); * var imag = require( '@stdlib/complex/float64/imag' ); * * var A = new Complex128Array( 5 ); +* * var alpha = new Complex128( 1.0, 2.0 ); * var beta = new Complex128( 3.0, 4.0 ); * * zlaset( 'upper', 2, 2, alpha, beta, A, 2, 1, 1 ); -* var z = A.get( 0 ); * -* real( z ) -* // => 3.0 +* var z = A.get( 1 ); +* // returns +* +* var re = real( z ); +* // returns 3.0 +* +* var im = imag( z ); +* // returns 4.0 +* +* z = A.get( 2 ); +* // returns * -* imag( z ) -* // => 4.0 +* re = real( z ); +* // returns 1.0 +* +* im = imag( z ); +* // returns 2.0 +* +* z = A.get( 3 ); +* // returns +* +* re = real( z ); +* // returns 0.0 +* +* im = imag( z ); +* // returns 0.0 * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); * * var A = new Complex128Array( 5 ); +* * var alpha = new Complex128( 1.0, 2.0 ); * var beta = new Complex128( 3.0, 4.0 ); * * zlaset( 'lower', 2, 2, alpha, beta, A, 2, 1, 1 ); -* var z = A.get( 0 ); * -* real( z ) -* // => 3.0 +* var z = A.get( 1 ); +* // returns +* +* var re = real( z ); +* // returns 3.0 +* +* var im = imag( z ); +* // returns 4.0 +* +* z = A.get( 2 ); +* // returns +* +* re = real( z ); +* // returns 0.0 +* +* im = imag( z ); +* // returns 0.0 +* +* z = A.get( 3 ); +* // returns +* +* re = real( z ); +* // returns 1.0 * -* imag( z ) -* // => 4.0 +* im = imag( z ); +* // returns 2.0 */ function zlaset( 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/zlaset/lib/zlaset.js b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/zlaset.js index 71cadcea258a..fae96a94c234 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/zlaset.js +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/zlaset.js @@ -28,10 +28,10 @@ var base = require( './base.js' ); // MAIN // /** -* Initialize the off-diagonal elements and the diagonal elements of a matrix to given values. +* Sets the off-diagonal elements and the diagonal elements of a matrix to specified values. * * @param {string} order - storage layout of `A` -* @param {string} uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param {string} uplo - specifies whether to set the upper or lower triangular/trapezoidal part of matrix `A` * @param {NonNegativeInteger} M - number of rows in matrix `A` * @param {NonNegativeInteger} N - number of columns in matrix `A` * @param {Complex128} alpha - value assigned to off-diagonal elements @@ -39,7 +39,6 @@ var base = require( './base.js' ); * @param {Complex128Array} 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 -* @throws {RangeError} sixth argument must be greater than or equal to `N` * @throws {RangeError} eighth argument must be greater than or equal to `N` * @returns {Complex128Array} `A` * @@ -50,17 +49,38 @@ var base = require( './base.js' ); * var imag = require( '@stdlib/complex/float64/imag' ); * * var A = new Complex128Array( 4 ); +* * var alpha = new Complex128( 1.0, 2.0 ); * var beta = new Complex128( 3.0, 4.0 ); * * zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, 2 ); +* * var z = A.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns 3.0 +* +* var im = imag( z ); +* // returns 4.0 +* +* z = A.get( 1 ); +* // returns +* +* re = real( z ); +* // returns 1.0 * -* real( z ) -* // => 3.0 +* im = imag( z ); +* // returns 2.0 * -* imag( z ) -* // => 4.0 +* z = A.get( 2 ); +* // returns +* +* re = real( z ); +* // returns 1.0 +* +* im = imag( z ); +* // returns 2.0 * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); @@ -69,17 +89,38 @@ var base = require( './base.js' ); * var imag = require( '@stdlib/complex/float64/imag' ); * * var A = new Complex128Array( 4 ); +* * var alpha = new Complex128( 1.0, 2.0 ); * var beta = new Complex128( 3.0, 4.0 ); * * zlaset( 'row-major', 'upper', 2, 2, alpha, beta, A, 2 ); +* * var z = A.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns 3.0 +* +* var im = imag( z ); +* // returns 4.0 * -* real( z ) -* // => 3.0 +* z = A.get( 1 ); +* // returns * -* imag( z ) -* // => 4.0 +* re = real( z ); +* // returns 1.0 +* +* im = imag( z ); +* // returns 2.0 +* +* z = A.get( 2 ); +* // returns +* +* re = real( z ); +* // returns 0.0 +* +* im = imag( z ); +* // returns 0.0 * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); @@ -88,17 +129,38 @@ var base = require( './base.js' ); * var imag = require( '@stdlib/complex/float64/imag' ); * * var A = new Complex128Array( 4 ); +* * var alpha = new Complex128( 1.0, 2.0 ); * var beta = new Complex128( 3.0, 4.0 ); * * zlaset( 'row-major', 'lower', 2, 2, alpha, beta, A, 2 ); +* * var z = A.get( 0 ); +* // returns +* +* var re = real( z ); +* // returns 3.0 +* +* var im = imag( z ); +* // returns 4.0 +* +* z = A.get( 1 ); +* // returns +* +* re = real( z ); +* // returns 0.0 +* +* im = imag( z ); +* // returns 0.0 +* +* z = A.get( 2 ); +* // returns * -* real( z ) -* // => 3.0 +* re = real( z ); +* // returns 1.0 * -* imag( z ) -* // => 4.0 +* im = imag( z ); +* // returns 2.0 */ function zlaset( order, uplo, M, N, alpha, beta, A, LDA ) { var sa1; From 9e42453da6caef9227f1e3f427b7daa3a3f1540a Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sun, 19 Jan 2025 02:32:58 -0800 Subject: [PATCH 5/7] bench: fix benchmarks and update docs --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../lapack/base/zlaset/benchmark/benchmark.js | 15 ++++++---- .../zlaset/benchmark/benchmark.ndarray.js | 30 ++++++++++--------- .../@stdlib/lapack/base/zlaset/docs/repl.txt | 16 +++++----- .../lapack/base/zlaset/docs/types/index.d.ts | 19 +++++------- .../lapack/base/zlaset/docs/types/test.ts | 22 +++++++------- .../lapack/base/zlaset/examples/index.js | 3 -- 6 files changed, 51 insertions(+), 54 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/zlaset/benchmark/benchmark.js index 682e13b9d9be..a169f03a8394 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/benchmark/benchmark.js @@ -21,6 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); +var Float64Array = require( '@stdlib/array/float64' ); var Complex128Array = require( '@stdlib/array/complex128' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); @@ -42,12 +43,15 @@ var zlaset = require( './../lib/zlaset.js' ); function createBenchmark( N ) { var alpha; var beta; + var abuf; var A; alpha = new Complex128( 1.0, 2.0 ); beta = new Complex128( 3.0, 4.0 ); - A = new Complex128Array( N*N ); + abuf = new Float64Array( N*N*2 ); + A = new Complex128Array( abuf.buffer ); + return benchmark; /** @@ -57,18 +61,17 @@ function createBenchmark( N ) { * @param {Benchmark} b - benchmark instance */ function benchmark( b ) { - var z; var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = zlaset( 'column-major', 'all', N, N, alpha, beta, A, N ); - if ( isnan( z[ i%z.length ] ) ) { + zlaset( 'column-major', 'all', N, N, alpha, beta, A, N ); + if ( isnan( abuf[ i%abuf.length ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( z[ i%z.length ] ) ) { + if ( isnan( abuf[ i%abuf.length ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); @@ -97,7 +100,7 @@ function main() { 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 ); + bench( pkg+'::equidimensional:order=column-major,size='+(N*N), f ); } } diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/zlaset/benchmark/benchmark.ndarray.js index b8cd5556320a..f1c535b69f60 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/benchmark/benchmark.ndarray.js @@ -21,12 +21,14 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/array/uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); 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 dlacpy = require( './../lib/ndarray.js' ); +var zlaset = require( './../lib/ndarray.js' ); // FUNCTIONS // @@ -39,16 +41,17 @@ var dlacpy = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( N ) { - var opts; + var alpha; + var beta; + var abuf; var A; - var B; - opts = { - 'dtype': 'float64' - }; + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + abuf = new Float64Array( N*N*2 ); + A = new Complex128Array( abuf.buffer ); - A = uniform( N*N, -10.0, 10.0, opts ); - B = uniform( N*N, -10.0, 10.0, opts ); return benchmark; /** @@ -58,18 +61,17 @@ function createBenchmark( N ) { * @param {Benchmark} b - benchmark instance */ function benchmark( b ) { - var z; var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dlacpy( 'all', N, N, A, 1, N, 0, B, 1, N, 0 ); - if ( isnan( z[ i%z.length ] ) ) { + zlaset( 'all', N, N, alpha, beta, A, 1, N, 0 ); + if ( isnan( abuf[ i%abuf.length ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( z[ i%z.length ] ) ) { + if ( isnan( abuf[ i%abuf.length ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); @@ -98,7 +100,7 @@ function main() { 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 ); + bench( pkg+'::equidimensional:ndarray:order=column-major,size='+(N*N), f ); } } diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/repl.txt index f1441e77985d..7483f2fd05c0 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( order, uplo, M, N, alpha, beta, A, LDA ) - Initializes the off-diagonal elements and the diagonal elements of a matrix - `A` to given values. + Sets the off-diagonal elements and the diagonal elements of a matrix `A` to + specified values. Indexing is relative to the first index. To introduce an offset, use typed array views. @@ -38,7 +38,7 @@ Returns ------- A: Complex128Array - Output matrix. + Input matrix. Examples -------- @@ -54,12 +54,12 @@ {{alias}}.ndarray( uplo, M, N, alpha, beta, A, sa1, sa2, oa ) - Initializes the off-diagonal elements and the diagonal elements of a matrix - `A` to given values using alternative indexing semantics. + Sets the off-diagonal elements and the diagonal elements of a matrix `A` to + specified values 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. + buffer, the offset parameter supports indexing semantics based on a starting + index. Parameters ---------- @@ -94,7 +94,7 @@ Returns ------- A: Complex128Array - Output matrix. + Input matrix. Examples -------- diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/index.d.ts index 0451298a9509..edef03387319 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/index.d.ts @@ -29,10 +29,10 @@ import { Layout } from '@stdlib/types/blas'; */ interface Routine { /** - * Initializes the off-diagonal elements and the diagonal elements of a matrix to given values. + * Sets the off-diagonal elements and the diagonal elements of a matrix to specified values. * * @param order - storage layout of `A` - * @param uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` + * @param uplo - specifies whether to set the upper or lower triangular/trapezoidal part of matrix `A` * @param M - number of rows in matrix `A` * @param N - number of columns in matrix `A` * @param alpha - value assigned to off-diagonal elements @@ -44,10 +44,9 @@ interface Routine { * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); * * var A = new Complex128Array( 4 ); + * * var alpha = new Complex128( 1.0, 2.0 ); * var beta = new Complex128( 3.0, 4.0 ); * @@ -57,9 +56,9 @@ interface Routine { ( order: Layout, uplo: string, M: number, N: number, alpha: Complex128, beta: Complex128, A: Complex128Array, LDA: number ): Complex128Array; /** - * Initializes the off-diagonal elements and the diagonal elements of a matrix to given values. + * Sets the off-diagonal elements and the diagonal elements of a matrix to specified values using alternative indexing semantics. * - * @param uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` + * @param uplo - specifies whether to set the upper or lower triangular/trapezoidal part of matrix `A` * @param M - number of rows in matrix `A` * @param N - number of columns in matrix `A` * @param alpha - value assigned to off-diagonal elements @@ -73,8 +72,6 @@ interface Routine { * @example * var Complex128Array = require( '@stdlib/array/float64' ); * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); * * var A = new Complex128Array( 4 ); * @@ -88,10 +85,10 @@ interface Routine { } /** -* Initializes the off-diagonal elements and the diagonal elements of a matrix to given values. +* Sets the off-diagonal elements and the diagonal elements of a matrix to specified values. * * @param order - storage layout of `A` -* @param uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param uplo - specifies whether to set the upper or lower triangular/trapezoidal part of matrix `A` * @param M - number of rows in matrix `A` * @param N - number of columns in matrix `A` * @param alpha - value assigned to off-diagonal elements @@ -102,8 +99,6 @@ interface Routine { * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); * * var A = new Complex128Array( 4 ); * diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/test.ts index 303841bad361..57b1e7a37fa9 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/test.ts +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/test.ts @@ -96,7 +96,7 @@ import zlaset = require( './index' ); zlaset( 'row-major', 'all', 2, ( x: number ): number => x, alpha, beta, A, 2 ); // $ExpectError } -// The compiler throws an error if the function is provided a fifth argument which is not a Complex128... +// The compiler throws an error if the function is provided a fifth argument which is not a complex number... { const A = new Complex128Array( 4 ); const beta = new Complex128( 3.0, 4.0 ); @@ -112,7 +112,7 @@ import zlaset = require( './index' ); zlaset( 'row-major', 'all', 2, 2, ( x: number ): number => x, beta, A, 2 ); // $ExpectError } -// The compiler throws an error if the function is provided a sixth argument which is not a Complex128... +// The compiler throws an error if the function is provided a sixth argument which is not a complex number... { const A = new Complex128Array( 4 ); const alpha = new Complex128( 1.0, 2.0 ); @@ -185,7 +185,7 @@ import zlaset = require( './index' ); zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectType Complex128Array } -// The compiler throws an error if the function is provided a first argument which is not a string... +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a string... { const A = new Complex128Array( 4 ); const alpha = new Complex128( 1.0, 2.0 ); @@ -201,7 +201,7 @@ import zlaset = require( './index' ); zlaset.ndarray( ( x: number ): number => x, 2, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a second argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... { const A = new Complex128Array( 4 ); const alpha = new Complex128( 1.0, 2.0 ); @@ -217,7 +217,7 @@ import zlaset = require( './index' ); zlaset.ndarray( 'all', ( x: number ): number => x, 2, alpha, beta, A, 2, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a third argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... { const A = new Complex128Array( 4 ); const alpha = new Complex128( 1.0, 2.0 ); @@ -233,7 +233,7 @@ import zlaset = require( './index' ); zlaset.ndarray( 'all', 2, ( x: number ): number => x, alpha, beta, A, 2, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a fourth argument which is not a Complex128... +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a complex number... { const A = new Complex128Array( 4 ); const beta = new Complex128( 3.0, 4.0 ); @@ -249,7 +249,7 @@ import zlaset = require( './index' ); zlaset.ndarray( 'all', 2, 2, ( x: number ): number => x, beta, A, 2, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a fifth argument which is not a Complex128... +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a complex number... { const A = new Complex128Array( 4 ); const alpha = new Complex128( 3.0, 4.0 ); @@ -265,7 +265,7 @@ import zlaset = require( './index' ); zlaset.ndarray( 'all', 2, 2, alpha, ( x: number ): number => x, A, 2, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a sixth argument which is not a Complex128Array... +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a Complex128Array... { const alpha = new Complex128( 1.0, 2.0 ); const beta = new Complex128( 3.0, 4.0 ); @@ -281,7 +281,7 @@ import zlaset = require( './index' ); zlaset.ndarray( 'all', 2, 2, alpha, beta, ( x: number ): number => x, 2, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a seventh argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... { const A = new Complex128Array( 4 ); const alpha = new Complex128( 1.0, 2.0 ); @@ -297,7 +297,7 @@ import zlaset = require( './index' ); zlaset.ndarray( 'all', 2, 2, alpha, beta, A, ( x: number ): number => x, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a eighth argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number... { const A = new Complex128Array( 4 ); const alpha = new Complex128( 1.0, 2.0 ); @@ -313,7 +313,7 @@ import zlaset = require( './index' ); zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, ( x: number ): number => x, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a ninth argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a number... { const A = new Complex128Array( 4 ); const alpha = new Complex128( 1.0, 2.0 ); diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/examples/index.js b/lib/node_modules/@stdlib/lapack/base/zlaset/examples/index.js index 64699f09a545..44e451212a05 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/examples/index.js @@ -35,10 +35,7 @@ var A = new Complex128Array( N ); console.log( ndarray2array( A, shape, strides, 0, order ) ); var alpha = new Complex128( 1.0, 2.0 ); -console.log(alpha); - var beta = new Complex128( 3.0, 4.0 ); -console.log(beta); zlaset( order, 'all', shape[ 0 ], shape[ 1 ], alpha, beta, A, strides[ 0 ] ); console.log( ndarray2array( A, shape, strides, 0, order ) ); From 7b3b61c58e0620410fc6885ff0a495a42949bccf Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sun, 19 Jan 2025 02:40:15 -0800 Subject: [PATCH 6/7] docs: update descriptions and copy --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../@stdlib/lapack/base/zlaset/README.md | 47 ++++++++++++++----- .../@stdlib/lapack/base/zlaset/docs/repl.txt | 9 ++-- .../lapack/base/zlaset/docs/types/index.d.ts | 6 +-- .../@stdlib/lapack/base/zlaset/lib/base.js | 8 ++-- .../@stdlib/lapack/base/zlaset/lib/index.js | 2 +- .../@stdlib/lapack/base/zlaset/lib/ndarray.js | 2 +- .../@stdlib/lapack/base/zlaset/lib/zlaset.js | 2 +- .../@stdlib/lapack/base/zlaset/package.json | 11 +++-- 8 files changed, 58 insertions(+), 29 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/README.md b/lib/node_modules/@stdlib/lapack/base/zlaset/README.md index 0e9103d32a17..a537dfa8313d 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/README.md +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/README.md @@ -20,7 +20,7 @@ limitations under the License. # zlaset -> Initialize the off-diagonal elements and the diagonal elements of a matrix to given values. +> Set the off-diagonal elements and the diagonal elements of a double-precision complex floating-point matrix to specified values.
@@ -32,7 +32,7 @@ var zlaset = require( '@stdlib/lapack/base/zlaset' ); #### zlaset( order, uplo, M, N, alpha, beta, A, LDA ) -Initializes the off-diagonal elements and the diagonal elements of a matrix to given values. +Sets the off-diagonal elements and the diagonal elements of a double-precision complex floating-point matrix to specified values. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); @@ -41,6 +41,7 @@ var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); var A = new Complex128Array( 4 ); + var alpha = new Complex128( 1.0, 2.0 ); var beta = new Complex128( 3.0, 4.0 ); @@ -54,6 +55,15 @@ var re = real( z ); var im = imag( z ); // returns 4.0 + +z = A.get( 1 ); +// returns + +re = real( z ); +// returns 1.0 + +im = imag( z ); +// returns 2.0 ``` The function has the following parameters: @@ -77,10 +87,10 @@ var Complex128 = require( '@stdlib/complex/float64/ctor' ); var real = require( '@stdlib/complex/float64/real' ); var imag = require( '@stdlib/complex/float64/imag' ); -// Initial array... +// Initial array: var A0 = new Complex128Array( 5 ); -// Create offset view... +// Create offset view: var A1 = new Complex128Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element var alpha = new Complex128( 1.0, 2.0 ); @@ -100,7 +110,7 @@ var im = imag( z ); #### zlaset.ndarray( uplo, M, N, alpha, beta, A, sa1, sa2, oa ) -Initializes the off-diagonal elements and the diagonal elements of a matrix to given values using alternative indexing semantics. +Sets the off-diagonal elements and the diagonal elements of a double-precision complex floating-point matrix to specified values using alternative indexing semantics. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); @@ -123,6 +133,15 @@ var re = real( z ); var im = imag( z ); // returns 4.0 + +z = A.get( 1 ); +// returns + +re = real( z ); +// returns 1.0 + +im = imag( z ); +// returns 2.0 ``` The function has the following parameters: @@ -137,7 +156,7 @@ The function has the following parameters: - **sa2**: stride of the second dimension of `A`. - **oa**: starting index for `A`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); @@ -152,13 +171,22 @@ var beta = new Complex128( 3.0, 4.0 ); zlaset.ndarray( 'all', 2, 2, alpha, beta, A, 2, 1, 1 ); -var z = A.get( 1 ); +var z = A.get( 0 ); // returns var re = real( z ); -// returns 3.0 +// returns 0.0 var im = imag( z ); +// returns 0.0 + +z = A.get( 1 ); +// returns + +re = real( z ); +// returns 3.0 + +im = imag( z ); // returns 4.0 ``` @@ -200,10 +228,7 @@ var A = new Complex128Array( N ); console.log( ndarray2array( A, shape, strides, 0, order ) ); var alpha = new Complex128( 1.0, 2.0 ); -console.log(alpha); - var beta = new Complex128( 3.0, 4.0 ); -console.log(beta); zlaset( order, 'all', shape[ 0 ], shape[ 1 ], alpha, beta, A, strides[ 0 ] ); console.log( ndarray2array( A, shape, strides, 0, order ) ); diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/repl.txt index 7483f2fd05c0..3e3c1767f725 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( order, uplo, M, N, alpha, beta, A, LDA ) - Sets the off-diagonal elements and the diagonal elements of a matrix `A` to - specified values. + Sets the off-diagonal elements and the diagonal elements of a double- + precision complex floating-point matrix `A` to specified values. Indexing is relative to the first index. To introduce an offset, use typed array views. @@ -54,8 +54,9 @@ {{alias}}.ndarray( uplo, M, N, alpha, beta, A, sa1, sa2, oa ) - Sets the off-diagonal elements and the diagonal elements of a matrix `A` to - specified values using alternative indexing semantics. + Sets the off-diagonal elements and the diagonal elements of a double- + precision complex floating-point matrix `A` to specified values using + alternative indexing semantics. While typed array views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/index.d.ts index edef03387319..5d067a66672b 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/docs/types/index.d.ts @@ -29,7 +29,7 @@ import { Layout } from '@stdlib/types/blas'; */ interface Routine { /** - * Sets the off-diagonal elements and the diagonal elements of a matrix to specified values. + * Sets the off-diagonal elements and the diagonal elements of a double-precision complex floating-point matrix to specified values. * * @param order - storage layout of `A` * @param uplo - specifies whether to set the upper or lower triangular/trapezoidal part of matrix `A` @@ -56,7 +56,7 @@ interface Routine { ( order: Layout, uplo: string, M: number, N: number, alpha: Complex128, beta: Complex128, A: Complex128Array, LDA: number ): Complex128Array; /** - * Sets the off-diagonal elements and the diagonal elements of a matrix to specified values using alternative indexing semantics. + * Sets the off-diagonal elements and the diagonal elements of a double-precision complex floating-point matrix to specified values using alternative indexing semantics. * * @param uplo - specifies whether to set the upper or lower triangular/trapezoidal part of matrix `A` * @param M - number of rows in matrix `A` @@ -85,7 +85,7 @@ interface Routine { } /** -* Sets the off-diagonal elements and the diagonal elements of a matrix to specified values. +* Sets the off-diagonal elements and the diagonal elements of a double-precision complex floating-point matrix to specified values. * * @param order - storage layout of `A` * @param uplo - specifies whether to set the upper or lower triangular/trapezoidal part of matrix `A` diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/base.js b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/base.js index 9c137d5cf9b5..ab3937650535 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/base.js @@ -31,7 +31,7 @@ var min = require( '@stdlib/math/base/special/fast/min' ); // FUNCTIONS // /** -* Sets the diagonal of a matrix `A` to a specified value. +* Sets the diagonal of a double-precision complex floating-point matrix `A` to a specified value. * * @private * @param {NonNegativeInteger} M - number of rows in matrix `A` @@ -84,7 +84,7 @@ function setDiagonal( M, N, breal, bimag, A, strideA1, strideA2, offsetA ) { } /** -* Sets all elements of a matrix `A` to specified values. +* Sets all elements of a double-precision complex floating-point matrix `A` to specified values. * * @private * @param {NonNegativeInteger} M - number of rows in matrix `A` @@ -213,7 +213,7 @@ function setAll( M, N, areal, aimag, breal, bimag, A, strideA1, strideA2, offset } /** -* Sets the upper triangular/trapezoidal part of a matrix `A` to specified values. +* Sets the upper triangular/trapezoidal part of a double-precision complex floating-point matrix `A` to specified values. * * @private * @param {NonNegativeInteger} M - number of rows in matrix `A` @@ -334,7 +334,7 @@ function setUpper( M, N, areal, aimag, breal, bimag, A, strideA1, strideA2, offs } /** -* Sets the lower triangular/trapezoidal part of a matrix `A` to specified values. +* Sets the lower triangular/trapezoidal part of a double-precision complex floating-point matrix `A` to specified values. * * @private * @param {NonNegativeInteger} M - number of rows in matrix `A` diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js index 5cd63c523fee..1321adf90b15 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* LAPACK routine to set the off-diagonal elements and the diagonal elements of a matrix to specified values. +* LAPACK routine to set the off-diagonal elements and the diagonal elements of a double-precision complex floating-point matrix to specified values. * * @module @stdlib/lapack/base/zlaset * diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/ndarray.js index 8e7880dbd625..49a6ffe1360a 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/ndarray.js @@ -26,7 +26,7 @@ var base = require( './base.js' ); // MAIN // /** -* Sets the off-diagonal elements and the diagonal elements of a matrix to specified values. +* Sets the off-diagonal elements and the diagonal elements of a double-precision complex floating-point matrix to specified values. * * @param {string} uplo - specifies whether to set the upper or lower triangular/trapezoidal part of matrix `A` * @param {NonNegativeInteger} M - number of rows in matrix `A` diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/zlaset.js b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/zlaset.js index fae96a94c234..d2a89594e7ab 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/lib/zlaset.js +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/lib/zlaset.js @@ -28,7 +28,7 @@ var base = require( './base.js' ); // MAIN // /** -* Sets the off-diagonal elements and the diagonal elements of a matrix to specified values. +* Sets the off-diagonal elements and the diagonal elements of a double-precision complex floating-point matrix to specified values. * * @param {string} order - storage layout of `A` * @param {string} uplo - specifies whether to set the upper or lower triangular/trapezoidal part of matrix `A` diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/package.json b/lib/node_modules/@stdlib/lapack/base/zlaset/package.json index f26f715c3178..632bda7f1d59 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/package.json +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/package.json @@ -1,7 +1,7 @@ { - "name": "@stdlib/lapack/base/dlacpy", + "name": "@stdlib/lapack/base/zlaset", "version": "0.0.0", - "description": "Initialize the off-diagonal elements and the diagonal elements of a matrix to given values.", + "description": "Set the off-diagonal elements and the diagonal elements of a double-precision complex floating-point matrix to specified values.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -54,7 +54,7 @@ "mathematics", "math", "lapack", - "dlacpy", + "zlaset", "copy", "linear", "algebra", @@ -64,6 +64,9 @@ "matrix", "float64", "double", - "float64array" + "float64array", + "complex", + "cmplx", + "complex128array" ] } From b6f462020a502b5d170966316fbcded11bb41946 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sun, 19 Jan 2025 02:57:19 -0800 Subject: [PATCH 7/7] test: add and update test cases --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../lapack/base/zlaset/test/test.ndarray.js | 136 +++------ .../lapack/base/zlaset/test/test.zlaset.js | 263 ++++++++++++++---- 2 files changed, 238 insertions(+), 161 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.ndarray.js index a3132562c5ad..fbeb69a4ffd1 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.ndarray.js @@ -21,9 +21,9 @@ // MODULES // var tape = require( 'tape' ); +var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); var Complex128Array = require( '@stdlib/array/complex128' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); var zlaset = require( './../lib/ndarray.js' ); @@ -43,8 +43,6 @@ tape( 'the function has an arity of 9', function test( t ) { tape( 'the function assigns values to matrix `A` (row-major)', function test( t ) { var expected; var alpha; - var viewE; - var viewA; var beta; var out; var M; @@ -58,29 +56,20 @@ tape( 'the function assigns values to matrix `A` (row-major)', function test( t N = 3; A = new Complex128Array( ( M*N ) + 1 ); + + /* eslint-disable array-element-newline */ expected = new Complex128Array([ - 0.0, - 0.0, - 3.0, - 4.0, - 1.0, - 2.0, - 1.0, - 2.0, - 1.0, - 2.0, - 3.0, - 4.0, - 1.0, - 2.0 + 0.0, 0.0, + 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, + 1.0, 2.0, 3.0, 4.0, 1.0, 2.0 ]); - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); + + /* eslint-enable array-element-newline */ out = zlaset( 'all', 2, 3, alpha, beta, A, 3, 1, 1 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); A = new Complex128Array( ( M*N ) + 1); @@ -92,36 +81,26 @@ tape( 'the function assigns values to matrix `A` (row-major)', function test( t ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'all', 2, 3, alpha, beta, A, -3, -1, 6 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); A = new Complex128Array( ( M*N ) + 1 ); + + /* eslint-disable array-element-newline */ expected = new Complex128Array([ - 0.0, - 0.0, - 3.0, - 4.0, - 1.0, - 2.0, - 1.0, - 2.0, - 3.0, - 4.0, - 1.0, - 2.0, - 1.0, - 2.0 + 0.0, 0.0, + 3.0, 4.0, 1.0, 2.0, + 1.0, 2.0, 3.0, 4.0, + 1.0, 2.0, 1.0, 2.0 ]); - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); + + /* eslint-enable array-element-newline */ out = zlaset( 'all', 3, 2, alpha, beta, A, 2, 1, 1 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -129,8 +108,6 @@ tape( 'the function assigns values to matrix `A` (row-major)', function test( t tape( 'the function assigns values to matrix `A` (row-major, upper)', function test( t ) { var expected; var alpha; - var viewE; - var viewA; var beta; var out; var M; @@ -153,12 +130,10 @@ tape( 'the function assigns values to matrix `A` (row-major, upper)', function t ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'upper', 2, 3, alpha, beta, A, 3, 1, 1 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); A = new Complex128Array( ( M*N ) + 1 ); @@ -170,12 +145,10 @@ tape( 'the function assigns values to matrix `A` (row-major, upper)', function t ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'upper', 2, 3, alpha, beta, A, 3, -1, 3 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); A = new Complex128Array( ( M*N ) + 1 ); @@ -188,20 +161,16 @@ tape( 'the function assigns values to matrix `A` (row-major, upper)', function t ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'upper', 3, 2, alpha, beta, A, 2, 1, 1 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); t.end(); }); tape( 'the function assigns values to matrix `A` (row-major, lower)', function test( t ) { var expected; - var viewA; - var viewE; var alpha; var beta; var out; @@ -225,12 +194,10 @@ tape( 'the function assigns values to matrix `A` (row-major, lower)', function t ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'lower', 2, 3, alpha, beta, A, 3, 1, 1 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); A = new Complex128Array( ( M*N ) + 1 ); @@ -242,12 +209,10 @@ tape( 'the function assigns values to matrix `A` (row-major, lower)', function t ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'lower', 2, 3, alpha, beta, A, -3, 1, 4 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); A = new Complex128Array( ( M*N ) + 1 ); @@ -260,20 +225,16 @@ tape( 'the function assigns values to matrix `A` (row-major, lower)', function t ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'lower', 3, 2, alpha, beta, A, 2, 1, 1 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); t.end(); }); tape( 'the function assigns values to matrix `A` (column-major)', function test( t ) { var expected; - var viewA; - var viewE; var alpha; var beta; var out; @@ -298,12 +259,10 @@ tape( 'the function assigns values to matrix `A` (column-major)', function test( ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'all', 2, 3, alpha, beta, A, 1, 2, 1 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); A = new Complex128Array( ( M*N ) + 1 ); @@ -316,12 +275,10 @@ tape( 'the function assigns values to matrix `A` (column-major)', function test( ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'all', 2, 3, alpha, beta, A, 1, 2, 1 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); A = new Complex128Array( ( M*N ) + 1 ); @@ -333,20 +290,16 @@ tape( 'the function assigns values to matrix `A` (column-major)', function test( ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'all', 3, 2, alpha, beta, A, 1, 3, 1 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); t.end(); }); tape( 'the function assigns values to matrix `A` (column-major, upper)', function test( t ) { var expected; - var viewA; - var viewE; var alpha; var beta; var out; @@ -371,12 +324,10 @@ tape( 'the function assigns values to matrix `A` (column-major, upper)', functio ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'upper', 2, 3, alpha, beta, A, 1, 2, 1 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); A = new Complex128Array( ( M*N ) + 1 ); @@ -389,12 +340,10 @@ tape( 'the function assigns values to matrix `A` (column-major, upper)', functio ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'upper', 2, 3, alpha, beta, A, 1, 2, 1 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); A = new Complex128Array( ( M*N ) + 1 ); @@ -406,20 +355,16 @@ tape( 'the function assigns values to matrix `A` (column-major, upper)', functio ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'upper', 3, 2, alpha, beta, A, 1, 3, 1 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); t.end(); }); tape( 'the function assigns values to matrix `A` (column-major, lower)', function test( t ) { var expected; - var viewA; - var viewE; var alpha; var beta; var out; @@ -444,12 +389,10 @@ tape( 'the function assigns values to matrix `A` (column-major, lower)', functio ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'lower', 2, 3, alpha, beta, A, 1, 2, 1 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); A = new Complex128Array( ( M*N ) + 1 ); @@ -462,12 +405,10 @@ tape( 'the function assigns values to matrix `A` (column-major, lower)', functio ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'lower', 2, 3, alpha, beta, A, 1, 2, 1 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); A = new Complex128Array( ( M*N ) + 1 ); @@ -479,20 +420,16 @@ tape( 'the function assigns values to matrix `A` (column-major, lower)', functio ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'lower', 3, 2, alpha, beta, A, 1, 3, 1 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); t.end(); }); tape( 'the function assigns values to matrix `A` (column-major, lower, complex access patterns)', function test( t ) { var expected; - var viewA; - var viewE; var alpha; var beta; var out; @@ -521,12 +458,9 @@ tape( 'the function assigns values to matrix `A` (column-major, lower, complex a /* eslint-enable array-element-newline, no-multi-spaces */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); - out = zlaset( 'all', 3, 3, alpha, beta, A, 2, 6, 7 ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.zlaset.js b/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.zlaset.js index c0c6f6fd37b5..bdf5290295fd 100644 --- a/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.zlaset.js +++ b/lib/node_modules/@stdlib/lapack/base/zlaset/test/test.zlaset.js @@ -21,9 +21,9 @@ // MODULES // var tape = require( 'tape' ); +var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); var Complex128Array = require( '@stdlib/array/complex128' ); var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); var zlaset = require( './../lib/zlaset.js' ); @@ -70,7 +70,7 @@ tape( 'the function throws an error if provided an invalid first argument', func } }); -tape( 'the function throws an error if provided an invalid sixth argument (row-major)', function test( t ) { +tape( 'the function throws an error if provided an invalid eighth argument (row-major)', function test( t ) { var values; var alpha; var beta; @@ -98,38 +98,40 @@ tape( 'the function throws an error if provided an invalid sixth argument (row-m } }); -tape( 'the function throws an error if provided an invalid eighth argument (row-major)', function test( t ) { - var values; +tape( 'the function assigns values to matrix `A` (row-major, wide)', function test( t ) { + var expected; var alpha; var beta; + var out; var A; - var i; + var M; + var N; - values = [ - 0, - 1 - ]; + M = 3; + N = 4; - A = new Complex128Array( 4 ); + A = new Complex128Array( M*N ); alpha = new Complex128( 1.0, 2.0 ); beta = new Complex128( 3.0, 4.0 ); - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, 1.0, 2.0, + 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, + 1.0, 2.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0 + ]); - function badValue( value ) { - return function badValue() { - zlaset( 'row-major', 'all', 2, 2, alpha, beta, A, value ); - }; - } + /* eslint-enable array-element-newline */ + + out = zlaset( 'row-major', 'all', M, N, alpha, beta, A, N ); + t.strictEqual( out, A, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); }); -tape( 'the function assigns values to matrix `A` (row-major)', function test( t ) { +tape( 'the function assigns values to matrix `A` (row-major, tall)', function test( t ) { var expected; - var viewA; - var viewE; var alpha; var beta; var out; @@ -137,8 +139,8 @@ tape( 'the function assigns values to matrix `A` (row-major)', function test( t var M; var N; - M = 3; - N = 4; + M = 4; + N = 3; A = new Complex128Array( M*N ); alpha = new Complex128( 1.0, 2.0 ); @@ -146,26 +148,23 @@ tape( 'the function assigns values to matrix `A` (row-major)', function test( t /* eslint-disable array-element-newline */ expected = new Complex128Array([ - 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, 1.0, 2.0, - 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, - 1.0, 2.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0 + 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, + 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, + 1.0, 2.0, 1.0, 2.0, 3.0, 4.0, + 1.0, 2.0, 1.0, 2.0, 1.0, 2.0 ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'row-major', 'all', M, N, alpha, beta, A, N ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); t.end(); }); -tape( 'the function assigns values to matrix `A` (row-major, upper)', function test( t ) { +tape( 'the function assigns values to matrix `A` (row-major, upper, wide)', function test( t ) { var expected; - var viewA; - var viewE; var alpha; var beta; var out; @@ -188,20 +187,49 @@ tape( 'the function assigns values to matrix `A` (row-major, upper)', function t ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'row-major', 'upper', M, N, alpha, beta, A, N ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (row-major, upper, tall)', function test( t ) { + var expected; + var alpha; + var beta; + var out; + var A; + var M; + var N; + + M = 4; + N = 3; + + A = new Complex128Array( M*N ); + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, + 0.0, 0.0, 3.0, 4.0, 1.0, 2.0, + 0.0, 0.0, 0.0, 0.0, 3.0, 4.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 + ]); + + /* eslint-enable array-element-newline */ + + out = zlaset( 'row-major', 'upper', M, N, alpha, beta, A, N ); + t.strictEqual( out, A, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); t.end(); }); -tape( 'the function assigns values to matrix `A` (row-major, lower)', function test( t ) { +tape( 'the function assigns values to matrix `A` (row-major, lower, wide)', function test( t ) { var expected; - var viewA; - var viewE; var alpha; var beta; var out; @@ -224,20 +252,49 @@ tape( 'the function assigns values to matrix `A` (row-major, lower)', function t ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'row-major', 'lower', M, N, alpha, beta, A, N ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (row-major, lower, tall)', function test( t ) { + var expected; + var alpha; + var beta; + var out; + var A; + var M; + var N; + + M = 4; + N = 3; + + A = new Complex128Array( M*N ); + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 3.0, 4.0, 0.0, 0.0, 0.0, 0.0, + 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, + 1.0, 2.0, 1.0, 2.0, 3.0, 4.0, + 1.0, 2.0, 1.0, 2.0, 1.0, 2.0 + ]); + + /* eslint-enable array-element-newline */ + + out = zlaset( 'row-major', 'lower', M, N, alpha, beta, A, N ); + t.strictEqual( out, A, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); t.end(); }); -tape( 'the function assigns values to matrix `A` (column-major)', function test( t ) { +tape( 'the function assigns values to matrix `A` (column-major, wide)', function test( t ) { var expected; - var viewA; - var viewE; var alpha; var beta; var out; @@ -261,20 +318,48 @@ tape( 'the function assigns values to matrix `A` (column-major)', function test( ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'column-major', 'all', M, N, alpha, beta, A, M ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); t.end(); }); -tape( 'the function assigns values to matrix `A` (column-major, upper)', function test( t ) { +tape( 'the function assigns values to matrix `A` (column-major, tall)', function test( t ) { + var expected; + var alpha; + var beta; + var out; + var A; + var M; + var N; + + M = 4; + N = 3; + + A = new Complex128Array( M*N ); + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, 1.0, 2.0, + 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, + 1.0, 2.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0 + ]); + + /* eslint-enable array-element-newline */ + + out = zlaset( 'column-major', 'all', M, N, alpha, beta, A, M ); + t.strictEqual( out, A, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (column-major, upper, wide)', function test( t ) { var expected; - var viewA; - var viewE; var alpha; var beta; var out; @@ -298,20 +383,48 @@ tape( 'the function assigns values to matrix `A` (column-major, upper)', functio ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'column-major', 'upper', M, N, alpha, beta, A, M ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (column-major, upper, tall)', function test( t ) { + var expected; + var alpha; + var beta; + var out; + var A; + var M; + var N; + + M = 4; + N = 3; + + A = new Complex128Array( M*N ); + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 3.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 0.0, 0.0, + 1.0, 2.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 + ]); + + /* eslint-enable array-element-newline */ + + out = zlaset( 'column-major', 'upper', M, N, alpha, beta, A, M ); + t.strictEqual( out, A, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); t.end(); }); -tape( 'the function assigns values to matrix `A` (column-major, lower)', function test( t ) { +tape( 'the function assigns values to matrix `A` (column-major, lower, wide)', function test( t ) { var expected; - var viewA; - var viewE; var alpha; var beta; var out; @@ -335,12 +448,42 @@ tape( 'the function assigns values to matrix `A` (column-major, lower)', functio ]); /* eslint-enable array-element-newline */ - viewE = reinterpret( expected, 0 ); - viewA = reinterpret( A, 0 ); out = zlaset( 'column-major', 'lower', M, N, alpha, beta, A, M ); t.strictEqual( out, A, 'returns expected value' ); - t.deepEqual( viewA, viewE, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function assigns values to matrix `A` (column-major, lower, tall)', function test( t ) { + var expected; + var alpha; + var beta; + var out; + var A; + var M; + var N; + + M = 4; + N = 3; + + A = new Complex128Array( M*N ); + alpha = new Complex128( 1.0, 2.0 ); + beta = new Complex128( 3.0, 4.0 ); + + /* eslint-disable array-element-newline */ + expected = new Complex128Array([ + 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, 1.0, 2.0, + 0.0, 0.0, 3.0, 4.0, 1.0, 2.0, 1.0, 2.0, + 0.0, 0.0, 0.0, 0.0, 3.0, 4.0, 1.0, 2.0 + ]); + + /* eslint-enable array-element-newline */ + + out = zlaset( 'column-major', 'lower', M, N, alpha, beta, A, M ); + t.strictEqual( out, A, 'returns expected value' ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); t.end(); });