From 182b457fd619417866ec13432818cc2c1b01ad7e Mon Sep 17 00:00:00 2001 From: kaustubh Date: Tue, 4 Aug 2026 02:11:48 +0530 Subject: [PATCH 1/5] feat: add blas/ext/base/ctriu --- 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_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - 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: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - 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/blas/ext/base/ctriu/README.md | 360 ++++++++++++++++ .../ext/base/ctriu/benchmark/benchmark.js | 113 +++++ .../base/ctriu/benchmark/benchmark.native.js | 118 ++++++ .../base/ctriu/benchmark/benchmark.ndarray.js | 127 ++++++ .../benchmark/benchmark.ndarray.native.js | 132 ++++++ .../blas/ext/base/ctriu/benchmark/c/Makefile | 146 +++++++ .../base/ctriu/benchmark/c/benchmark.length.c | 212 ++++++++++ .../@stdlib/blas/ext/base/ctriu/binding.gyp | 170 ++++++++ .../@stdlib/blas/ext/base/ctriu/docs/repl.txt | 114 ++++++ .../blas/ext/base/ctriu/docs/types/index.d.ts | 118 ++++++ .../blas/ext/base/ctriu/docs/types/test.ts | 354 ++++++++++++++++ .../blas/ext/base/ctriu/examples/c/Makefile | 146 +++++++ .../blas/ext/base/ctriu/examples/c/example.c | 56 +++ .../blas/ext/base/ctriu/examples/index.js | 45 ++ .../@stdlib/blas/ext/base/ctriu/include.gypi | 53 +++ .../include/stdlib/blas/ext/base/ctriu.h | 46 +++ .../@stdlib/blas/ext/base/ctriu/lib/base.js | 114 ++++++ .../@stdlib/blas/ext/base/ctriu/lib/ctriu.js | 105 +++++ .../blas/ext/base/ctriu/lib/ctriu.native.js | 86 ++++ .../@stdlib/blas/ext/base/ctriu/lib/index.js | 70 ++++ .../@stdlib/blas/ext/base/ctriu/lib/main.js | 35 ++ .../@stdlib/blas/ext/base/ctriu/lib/native.js | 35 ++ .../blas/ext/base/ctriu/lib/ndarray.js | 69 ++++ .../blas/ext/base/ctriu/lib/ndarray.native.js | 64 +++ .../@stdlib/blas/ext/base/ctriu/manifest.json | 82 ++++ .../@stdlib/blas/ext/base/ctriu/package.json | 79 ++++ .../@stdlib/blas/ext/base/ctriu/src/Makefile | 70 ++++ .../@stdlib/blas/ext/base/ctriu/src/addon.c | 100 +++++ .../@stdlib/blas/ext/base/ctriu/src/main.c | 108 +++++ .../blas/ext/base/ctriu/test/test.ctriu.js | 376 +++++++++++++++++ .../ext/base/ctriu/test/test.ctriu.native.js | 385 ++++++++++++++++++ .../@stdlib/blas/ext/base/ctriu/test/test.js | 82 ++++ .../blas/ext/base/ctriu/test/test.ndarray.js | 296 ++++++++++++++ .../base/ctriu/test/test.ndarray.native.js | 310 ++++++++++++++ 34 files changed, 4776 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/include/stdlib/blas/ext/base/ctriu.h create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/base.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/ctriu.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/ctriu.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/src/main.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ctriu.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ctriu.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ndarray.native.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/README.md b/lib/node_modules/@stdlib/blas/ext/base/ctriu/README.md new file mode 100644 index 000000000000..7df6c51b66d8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/README.md @@ -0,0 +1,360 @@ + + +# ctriu + +> Copy the upper triangular part of a single-precision complex floating-point matrix `A` to another matrix `B`. + +
+ +
+ + + +
+ +## Usage + +```javascript +var ctriu = require( '@stdlib/blas/ext/base/ctriu' ); +``` + +#### ctriu( order, M, N, k, A, LDA, B, LDB ) + +Copies the upper triangular part of a single-precision complex floating-point matrix `A` to another matrix `B`. + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); + +var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var B = new Complex64Array( 4 ); + +ctriu( 'row-major', 2, 2, 0, A, 2, B, 2 ); +// B => [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **k**: diagonal below which to ignore. A value of `k = 0` refers to the main diagonal, `k < 0` refers to a diagonal below the main diagonal, and `k > 0` refers to a diagonal above the main diagonal. Accordingly, when `k < 0`, the function copies the upper triangle **and** one or more sub-diagonals (i.e., part of the lower triangle), and, when `k > 0`, the function copies only part of the upper triangle. +- **A**: input matrix. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **B**: output matrix. +- **LDB**: stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`). + +Setting the `k` parameter to a value other than `0` allows including and excluding sub- and super-diagonals, respectively. For example, to copy the upper triangle and the first sub-diagonal, + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); + +var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var B = new Complex64Array( 4 ); + +ctriu( 'row-major', 2, 2, -1, A, 2, B, 2 ); +// B => [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); + +// Initial arrays... +var A0 = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] ); +var B0 = new Complex64Array( 5 ); + +// Create offset views... +var A1 = new Complex64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var B1 = new Complex64Array( B0.buffer, B0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +ctriu( 'row-major', 2, 2, 0, A1, 2, B1, 2 ); +// B0 => [ 0.0, 0.0, 3.0, 4.0, 5.0, 6.0, 0.0, 0.0, 9.0, 10.0 ] +``` + +#### ctriu.ndarray( M, N, k, A, sa1, sa2, oa, B, sb1, sb2, ob ) + +Copies the upper triangular part of a single-precision complex floating-point matrix `A` to another matrix `B` using alternative indexing semantics. + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); + +var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var B = new Complex64Array( 4 ); + +ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); +// B => [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ] +``` + +The function has the following parameters: + +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **k**: diagonal below which to ignore. +- **A**: input matrix. +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A`. +- **B**: output matrix. +- **sb1**: stride of the first dimension of `B`. +- **sb2**: stride of the second dimension of `B`. +- **ob**: starting index for `B`. + +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 Complex64Array = require( '@stdlib/array/complex64' ); + +var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 2 ); +// B => [ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ] +``` + +
+ + + +
+ +## Notes + +- Elements outside of the copied region are left unchanged. + +
+ + + +
+ +## Examples + + + +```javascript +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var uniform = require( '@stdlib/random/array/discrete-uniform' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var ctriu = require( '@stdlib/blas/ext/base/ctriu' ); + +var shape = [ 5, 8 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +var N = numel( shape ); + +var A = uniform( N, -10, 10, { + 'dtype': 'complex64' +}); +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var B = uniform( N, -10, 10, { + 'dtype': 'complex64' +}); +console.log( ndarray2array( B, shape, strides, 0, order ) ); + +ctriu( order, shape[ 0 ], shape[ 1 ], 0, A, strides[ 0 ], B, strides[ 0 ] ); +console.log( ndarray2array( B, shape, strides, 0, order ) ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/ext/base/ctriu.h" +``` + +#### stdlib_strided_ctriu( layout, M, N, k, \*A, LDA, \*B, LDB ) + +Copies the upper triangular part of a single-precision complex floating-point matrix `A` to another matrix `B`. + +```c +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float32/ctor.h" + +const float A[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; +float B[] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + +stdlib_strided_ctriu( CblasRowMajor, 2, 2, 0, (stdlib_complex64_t *)A, 2, (stdlib_complex64_t *)B, 2 ); +``` + +The function accepts the following arguments: + +- **layout**: `[in] CBLAS_LAYOUT` storage layout. +- **M**: `[in] CBLAS_INT` number of rows in `A`. +- **N**: `[in] CBLAS_INT` number of columns in `A`. +- **k**: `[in] CBLAS_INT` diagonal below which to ignore. +- **A**: `[in] stdlib_complex64_t*` input matrix. +- **LDA**: `[in] CBLAS_INT` stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **B**: `[out] stdlib_complex64_t*` output matrix. +- **LDB**: `[in] CBLAS_INT` stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`). + +```c +void API_SUFFIX(stdlib_strided_ctriu)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const CBLAS_INT k, const stdlib_complex64_t *A, const CBLAS_INT LDA, stdlib_complex64_t *B, const CBLAS_INT LDB ); +``` + +#### stdlib_strided_ctriu_ndarray( M, N, k, \*A, sa1, sa2, oa, \*B, sb1, sb2, ob ) + +Copies the upper triangular part of a single-precision complex floating-point matrix `A` to another matrix `B` using alternative indexing semantics. + +```c +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float32/ctor.h" + +const float A[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f }; +float B[] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + +stdlib_strided_ctriu_ndarray( 2, 2, 0, (stdlib_complex64_t *)A, 2, 1, 0, (stdlib_complex64_t *)B, 2, 1, 0 ); +``` + +The function accepts the following arguments: + +- **M**: `[in] CBLAS_INT` number of rows in `A`. +- **N**: `[in] CBLAS_INT` number of columns in `A`. +- **k**: `[in] CBLAS_INT` diagonal below which to ignore. +- **A**: `[in] stdlib_complex64_t*` input matrix. +- **sa1**: `[in] CBLAS_INT` stride of the first dimension of `A`. +- **sa2**: `[in] CBLAS_INT` stride of the second dimension of `A`. +- **oa**: `[in] CBLAS_INT` starting index for `A`. +- **B**: `[out] stdlib_complex64_t*` output matrix. +- **sb1**: `[in] CBLAS_INT` stride of the first dimension of `B`. +- **sb2**: `[in] CBLAS_INT` stride of the second dimension of `B`. +- **ob**: `[in] CBLAS_INT` starting index for `B`. + +```c +void API_SUFFIX(stdlib_strided_ctriu_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const CBLAS_INT k, const stdlib_complex64_t *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, stdlib_complex64_t *B, const CBLAS_INT strideB1, const CBLAS_INT strideB2, const CBLAS_INT offsetB ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/ext/base/ctriu.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float32/ctor.h" +#include + +int main( void ) { + // Define a 3x3 input matrix stored in row-major order: + const float A[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f }; + + // Define a 3x3 output matrix: + float B[] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + + // Specify the number of elements along each dimension of `A`: + const CBLAS_INT M = 3; + const CBLAS_INT N = 3; + + // Copy the upper triangular part of `A` to `B`: + stdlib_strided_ctriu( CblasRowMajor, M, N, 0, (stdlib_complex64_t *)A, N, (stdlib_complex64_t *)B, N ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + int idx = ( (i*N) + j ) * 2; + printf( "B[ %i,%i ] = %f + %fi\n", i, j, B[ idx ], B[ idx+1 ] ); + } + } + + // Copy the upper triangular part of `A`, including the first sub-diagonal, to `B` using alternative indexing semantics: + stdlib_strided_ctriu_ndarray( M, N, -1, (stdlib_complex64_t *)A, N, 1, 0, (stdlib_complex64_t *)B, N, 1, 0 ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + int idx = ( (i*N) + j ) * 2; + printf( "B[ %i,%i ] = %f + %fi\n", i, j, B[ idx ], B[ idx+1 ] ); + } + } +} +``` + +
+ + + +
+ + + +
+ +
+ + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.js new file mode 100644 index 000000000000..ba10fefeaf12 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.js @@ -0,0 +1,113 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var realf = require( '@stdlib/complex/float32/real' ); +var zeros = require( '@stdlib/array/zeros' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var ctriu = require( './../lib' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var A = zeros( N*N, 'complex64' ); + var B = zeros( N*N, 'complex64' ); + 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 = ctriu( order, N, N, 0, A, N, B, N ); + if ( isnanf( realf( z.get( i%z.length ) ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( realf( z.get( 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 ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s::square_matrix:order=%s,size=%d', pkg, ord, N*N ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.native.js new file mode 100644 index 000000000000..9e80589232d9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.native.js @@ -0,0 +1,118 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var realf = require( '@stdlib/complex/float32/real' ); +var zeros = require( '@stdlib/array/zeros' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var ctriu = tryRequire( resolve( __dirname, './../lib/ctriu.native.js' ) ); +var opts = { + 'skip': ( ctriu instanceof Error ) +}; +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var A = zeros( N*N, 'complex64' ); + var B = zeros( N*N, 'complex64' ); + 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 = ctriu( order, N, N, 0, A, N, B, N ); + if ( isnanf( realf( z.get( i%z.length ) ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( realf( z.get( 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 ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s::native,square_matrix:order=%s,size=%d', pkg, ord, N*N ), opts, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..0dfafb3a6ebe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.ndarray.js @@ -0,0 +1,127 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var realf = require( '@stdlib/complex/float32/real' ); +var zeros = require( '@stdlib/array/zeros' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var ctriu = require( './../lib' ).ndarray; + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var sa1; + var sa2; + var A; + var B; + + A = zeros( N*N, 'complex64' ); + B = zeros( N*N, 'complex64' ); + + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = N; + } else { // order === 'row-major' + sa1 = N; + sa2 = 1; + } + 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 = ctriu( N, N, 0, A, sa1, sa2, 0, B, sa1, sa2, 0 ); + if ( isnanf( realf( z.get( i%z.length ) ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( realf( z.get( 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 ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s::square_matrix:ndarray:order=%s,size=%d', pkg, ord, N*N ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..870fa92cb208 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,132 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var realf = require( '@stdlib/complex/float32/real' ); +var zeros = require( '@stdlib/array/zeros' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var ctriu = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( ctriu instanceof Error ) +}; +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var sa1; + var sa2; + var A; + var B; + + A = zeros( N*N, 'complex64' ); + B = zeros( N*N, 'complex64' ); + + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = N; + } else { // order === 'row-major' + sa1 = N; + sa2 = 1; + } + 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 = ctriu( N, N, 0, A, sa1, sa2, 0, B, sa1, sa2, 0 ); + if ( isnanf( realf( z.get( i%z.length ) ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( realf( z.get( 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 ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s::native,square_matrix:ndarray:order=%s,size=%d', pkg, ord, N*N ), opts, f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/c/Makefile new file mode 100644 index 000000000000..0756dc7da20a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.length.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..9a421dc27969 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/c/benchmark.length.c @@ -0,0 +1,212 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +#include "stdlib/blas/ext/base/ctriu.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float32/ctor.h" +#include +#include +#include +#include +#include + +#define NAME "ctriu" +#define ITERATIONS 1000000 +#define REPEATS 3 +#define MIN 1 +#define MAX 6 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param iterations number of iterations +* @param elapsed elapsed time in seconds +*/ +static void print_results( int iterations, double elapsed ) { + double rate = (double)iterations / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", iterations ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [min,max). +* +* @param min minimum value (inclusive) +* @param max maximum value (exclusive) +* @return random number +*/ +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v*(max-min) ); +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param N number of elements along each dimension +* @return elapsed time in seconds +*/ +static double benchmark1( int iterations, int N ) { + double elapsed; + float *A; + float *B; + double t; + int i; + + A = (float *)malloc( 2 * N * N * sizeof( float ) ); + B = (float *)malloc( 2 * N * N * sizeof( float ) ); + for ( i = 0; i < 2 * N * N; i++ ) { + A[ i ] = (float)random_uniform( -10.0, 10.0 ); + B[ i ] = 0.0f; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + stdlib_strided_ctriu( CblasRowMajor, N, N, 0, (stdlib_complex64_t *)A, N, (stdlib_complex64_t *)B, N ); + if ( B[ 0 ] != B[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( B[ 0 ] != B[ 0 ] ) { + printf( "should not return NaN\n" ); + } + free( A ); + free( B ); + return elapsed; +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param N number of elements along each dimension +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int N ) { + double elapsed; + float *A; + float *B; + double t; + int i; + + A = (float *)malloc( 2 * N * N * sizeof( float ) ); + B = (float *)malloc( 2 * N * N * sizeof( float ) ); + for ( i = 0; i < 2 * N * N; i++ ) { + A[ i ] = (float)random_uniform( -10.0, 10.0 ); + B[ i ] = 0.0f; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + // cppcheck-suppress uninitvar + stdlib_strided_ctriu_ndarray( N, N, 0, (stdlib_complex64_t *)A, N, 1, 0, (stdlib_complex64_t *)B, N, 1, 0 ); + if ( B[ 0 ] != B[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( B[ 0 ] != B[ 0 ] ) { + printf( "should not return NaN\n" ); + } + free( A ); + free( B ); + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int len; + int N; + int i; + int j; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + count = 0; + for ( i = MIN; i <= MAX; i++ ) { + len = pow( 10, i ); + N = (int)sqrt( (double)len ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s::square_matrix:order=row-major,size=%d\n", NAME, N*N ); + elapsed = benchmark1( iter, N ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + for ( i = MIN; i <= MAX; i++ ) { + len = pow( 10, i ); + N = (int)sqrt( (double)len ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s::square_matrix:ndarray:order=row-major,size=%d\n", NAME, N*N ); + elapsed = benchmark2( iter, N ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/binding.gyp b/lib/node_modules/@stdlib/blas/ext/base/ctriu/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/repl.txt new file mode 100644 index 000000000000..b8b95538d050 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/repl.txt @@ -0,0 +1,114 @@ + +{{alias}}( order, M, N, k, A, LDA, B, LDB ) + Copies the upper triangular part of a single-precision complex + floating-point matrix `A` to another matrix `B`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + The diagonal parameter `k` specifies the diagonal below which to ignore. A + value of `k = 0` refers to the main diagonal, `k < 0` refers to a diagonal + below the main diagonal, and `k > 0` refers to a diagonal above the main + diagonal. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + k: integer + Diagonal below which to ignore. + + A: Complex64Array + Input matrix `A`. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + B: Complex64Array + Output matrix `B`. + + LDB: integer + Stride of the first dimension of `B` (a.k.a., leading dimension of the + matrix `B`). + + Returns + ------- + B: Complex64Array + Output matrix. + + Examples + -------- + > var A = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > var B = new {{alias:@stdlib/array/complex64}}( 4 ); + > {{alias}}( 'row-major', 2, 2, 0, A, 2, B, 2 ) + [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ] + + +{{alias}}.ndarray( M, N, k, A, sa1, sa2, oa, B, sb1, sb2, ob ) + Copies the upper triangular part of a single-precision complex + floating-point matrix `A` to another matrix `B` 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 + ---------- + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + k: integer + Diagonal below which to ignore. + + A: Complex64Array + 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`. + + B: Complex64Array + Output matrix `B`. + + sb1: integer + Stride of the first dimension of `B`. + + sb2: integer + Stride of the second dimension of `B`. + + ob: integer + Starting index for `B`. + + Returns + ------- + B: Complex64Array + Output matrix. + + Examples + -------- + > var A = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > var B = new {{alias:@stdlib/array/complex64}}( 4 ); + > {{alias}}.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ) + [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/types/index.d.ts new file mode 100644 index 000000000000..f382a72844c6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/types/index.d.ts @@ -0,0 +1,118 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Layout } from '@stdlib/types/blas'; +import { Complex64Array } from '@stdlib/types/array'; + +/** +* Interface describing `ctriu`. +*/ +interface Routine { + /** + * Copies the upper triangular part of a single-precision complex floating-point matrix `A` to another matrix `B`. + * + * @param order - storage layout of `A` and `B` + * @param M - number of rows in matrix `A` + * @param N - number of columns in matrix `A` + * @param k - diagonal below which to ignore + * @param A - input matrix + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param B - output matrix + * @param LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) + * @returns `B` + * + * @example + * var Complex64Array = require( '@stdlib/array/complex64' ); + * + * var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + * var B = new Complex64Array( 4 ); + * + * ctriu( 'row-major', 2, 2, 0, A, 2, B, 2 ); + * // B => [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ] + */ + ( order: Layout, M: number, N: number, k: number, A: Complex64Array, LDA: number, B: Complex64Array, LDB: number ): Complex64Array; + + /** + * Copies the upper triangular part of a single-precision complex floating-point matrix `A` to another matrix `B` using alternative indexing semantics. + * + * @param M - number of rows in matrix `A` + * @param N - number of columns in matrix `A` + * @param k - diagonal below which to ignore + * @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` + * @param B - output matrix + * @param strideB1 - stride of the first dimension of `B` + * @param strideB2 - stride of the second dimension of `B` + * @param offsetB - starting index for `B` + * @returns `B` + * + * @example + * var Complex64Array = require( '@stdlib/array/complex64' ); + * + * var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + * var B = new Complex64Array( 4 ); + * + * ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); + * // B => [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ] + */ + ndarray( M: number, N: number, k: number, A: Complex64Array, strideA1: number, strideA2: number, offsetA: number, B: Complex64Array, strideB1: number, strideB2: number, offsetB: number ): Complex64Array; +} + +/** +* Copies the upper triangular part of a single-precision complex floating-point matrix `A` to another matrix `B`. +* +* @param order - storage layout of `A` and `B` +* @param M - number of rows in matrix `A` +* @param N - number of columns in matrix `A` +* @param k - diagonal below which to ignore +* @param A - input matrix +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param B - output matrix +* @param LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) +* @returns `B` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctriu( 'row-major', 2, 2, 0, A, 2, B, 2 ); +* // B => [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ] +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ] +*/ +declare var ctriu: Routine; + + +// EXPORTS // + +export = ctriu; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/types/test.ts new file mode 100644 index 000000000000..b5a2c3aacd88 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/types/test.ts @@ -0,0 +1,354 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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 ctriu = require( './index' ); + + +// TESTS // + +// The function returns a Complex64Array... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu( 'row-major', 2, 2, 0, A, 2, B, 2 ); // $ExpectType Complex64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a valid order... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu( 5, 2, 2, 0, A, 2, B, 2 ); // $ExpectError + ctriu( true, 2, 2, 0, A, 2, B, 2 ); // $ExpectError + ctriu( false, 2, 2, 0, A, 2, B, 2 ); // $ExpectError + ctriu( null, 2, 2, 0, A, 2, B, 2 ); // $ExpectError + ctriu( void 0, 2, 2, 0, A, 2, B, 2 ); // $ExpectError + ctriu( [], 2, 2, 0, A, 2, B, 2 ); // $ExpectError + ctriu( {}, 2, 2, 0, A, 2, B, 2 ); // $ExpectError + ctriu( ( x: number ): number => x, 2, 2, 0, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu( 'row-major', '5', 2, 0, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', true, 2, 0, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', false, 2, 0, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', null, 2, 0, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', void 0, 2, 0, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', [], 2, 0, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', {}, 2, 0, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', ( x: number ): number => x, 2, 0, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu( 'row-major', 2, '5', 0, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, true, 0, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, false, 0, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, null, 0, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, void 0, 0, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, [], 0, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, {}, 0, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, ( x: number ): number => x, 0, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu( 'row-major', 2, 2, '5', A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, true, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, false, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, null, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, void 0, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, [], A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, {}, A, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, ( x: number ): number => x, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Complex64Array... +{ + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu( 'row-major', 2, 2, 0, 5, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, true, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, false, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, null, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, void 0, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, [], 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, {}, 2, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, ( x: number ): number => x, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu( 'row-major', 2, 2, 0, A, '5', B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, true, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, false, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, null, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, void 0, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, [], B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, {}, B, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, ( x: number ): number => x, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Complex64Array... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + ctriu( 'row-major', 2, 2, 0, A, 2, 5, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2, true, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2, false, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2, null, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2, void 0, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2, [], 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2, {}, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2, ( 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 Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu( 'row-major', 2, 2, 0, A, 2, B, '5' ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2, B, true ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2, B, false ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2, B, null ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2, B, void 0 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2, B, [] ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2, B, {} ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2, B, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu(); // $ExpectError + ctriu( 'row-major' ); // $ExpectError + ctriu( 'row-major', 2 ); // $ExpectError + ctriu( 'row-major', 2, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2 ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2, B ); // $ExpectError + ctriu( 'row-major', 2, 2, 0, A, 2, B, 2, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Complex64Array... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectType Complex64Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu.ndarray( '5', 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( true, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( false, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( null, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( void 0, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( [], 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( {}, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( ( x: number ): number => x, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu.ndarray( 2, '5', 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, true, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, false, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, null, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, void 0, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, [], 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, {}, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, ( x: number ): number => x, 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu.ndarray( 2, 2, '5', A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, true, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, false, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, null, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, void 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, [], A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, {}, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, ( x: number ): number => x, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a Complex64Array... +{ + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu.ndarray( 2, 2, 0, 5, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, true, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, false, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, null, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, void 0, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, [], 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, {}, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, ( x: number ): number => x, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu.ndarray( 2, 2, 0, A, '5', 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, true, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, false, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, null, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, void 0, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, [], 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, {}, 1, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, ( x: number ): number => x, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu.ndarray( 2, 2, 0, A, 2, '5', 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, true, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, false, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, null, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, void 0, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, [], 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, {}, 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, ( x: number ): number => x, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu.ndarray( 2, 2, 0, A, 2, 1, '5', B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, true, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, false, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, null, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, void 0, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, [], B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, {}, B, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, ( x: number ): number => x, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a Complex64Array... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, 5, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, true, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, false, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, null, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, void 0, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, [], 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, {}, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, ( x: number ): number => x, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, '5', 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, true, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, false, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, null, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, void 0, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, [], 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, {}, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a tenth argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, '5', 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, true, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, false, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, null, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, void 0, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, [], 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, {}, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eleventh argument which is not a number... +{ + const A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, '5' ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, true ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, false ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, null ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, void 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, [] ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, {} ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 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 Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + + ctriu.ndarray(); // $ExpectError + ctriu.ndarray( 2 ); // $ExpectError + ctriu.ndarray( 2, 2 ); // $ExpectError + ctriu.ndarray( 2, 2, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1 ); // $ExpectError + ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0, 0 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/examples/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/ctriu/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/ctriu/examples/c/example.c new file mode 100644 index 000000000000..81fd6c34a57c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/examples/c/example.c @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +#include "stdlib/blas/ext/base/ctriu.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float32/ctor.h" +#include + +int main( void ) { + // Define a 3x3 input matrix stored in row-major order: + const float A[ 3*3*2 ] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f }; + + // Define a 3x3 output matrix: + float B[ 3*3*2 ] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + + // Specify the number of elements along each dimension of `A`: + const CBLAS_INT M = 3; + const CBLAS_INT N = 3; + + // Copy the upper triangular part of `A` to `B`: + stdlib_strided_ctriu( CblasRowMajor, M, N, 0, (stdlib_complex64_t *)A, N, (stdlib_complex64_t *)B, N ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + int idx = ( (i*N) + j ) * 2; + printf( "B[ %i,%i ] = %f + %fi\n", i, j, B[ idx ], B[ idx+1 ] ); + } + } + + // Copy the upper triangular part of `A`, including the first sub-diagonal, to `B` using alternative indexing semantics: + stdlib_strided_ctriu_ndarray( M, N, -1, (stdlib_complex64_t *)A, N, 1, 0, (stdlib_complex64_t *)B, N, 1, 0 ); + + // Print the result: + for ( int i = 0; i < M; i++ ) { + for ( int j = 0; j < N; j++ ) { + int idx = ( (i*N) + j ) * 2; + printf( "B[ %i,%i ] = %f + %fi\n", i, j, B[ idx ], B[ idx+1 ] ); + } + } +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/examples/index.js new file mode 100644 index 000000000000..ead551c2d245 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/examples/index.js @@ -0,0 +1,45 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var uniform = require( '@stdlib/random/array/discrete-uniform' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var ctriu = require( './../lib' ); + +var shape = [ 5, 8 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +var N = numel( shape ); + +var A = new Complex64Array( uniform( N*2, -10, 10, { + 'dtype': 'float32' +}).buffer ); +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var B = new Complex64Array( uniform( N*2, -10, 10, { + 'dtype': 'float32' +}).buffer ); +console.log( ndarray2array( B, shape, strides, 0, order ) ); + +ctriu( order, shape[ 0 ], shape[ 1 ], 0, A, strides[ 0 ], B, strides[ 0 ] ); +console.log( ndarray2array( B, shape, strides, 0, order ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/ctriu/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ] +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctriu( 2, 2, -1, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] +*/ +function ctriu( M, N, k, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { + var viewA; + var viewB; + var sa1; + var sa2; + var sb1; + var sb2; + var ia; + var ib; + var i0; + var i1; + + viewA = reinterpret( A, 0 ); + viewB = reinterpret( B, 0 ); + + sa1 = strideA1 * 2; + sa2 = strideA2 * 2; + sb1 = strideB1 * 2; + sb2 = strideB2 * 2; + ia = offsetA * 2; + ib = offsetB * 2; + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for ( i1 = 0; i1 < M; i1++ ) { + for ( i0 = max( 0, i1+k ); i0 < N; i0++ ) { + viewB[ ib+(i0*sb2) ] = viewA[ ia+(i0*sa2) ]; + viewB[ ib+(i0*sb2)+1 ] = viewA[ ia+(i0*sa2)+1 ]; + } + ia += sa1; + ib += sb1; + } + return B; + } + for ( i1 = 0; i1 < N; i1++ ) { + for ( i0 = 0; i0 <= min( i1-k, M-1 ); i0++ ) { + viewB[ ib+(i0*sb1) ] = viewA[ ia+(i0*sa1) ]; + viewB[ ib+(i0*sb1)+1 ] = viewA[ ia+(i0*sa1)+1 ]; + } + ia += sa2; + ib += sb2; + } + return B; +} + + +// EXPORTS // + +module.exports = ctriu; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/ctriu.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/ctriu.js new file mode 100644 index 000000000000..0cfa8bdcaf96 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/ctriu.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Copies the upper triangular part of a single-precision complex floating-point matrix `A` to another matrix `B`. +* +* @param {string} order - storage layout of `A` and `B` +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {integer} k - diagonal below which to ignore +* @param {Complex64Array} A - input matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Complex64Array} B - output matrix +* @param {PositiveInteger} LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} sixth argument must be a valid stride +* @throws {RangeError} eighth argument must be a valid stride +* @returns {Complex64Array} `B` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctriu( 'row-major', 2, 2, 0, A, 2, B, 2 ); +* // B => [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ] +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctriu( 'row-major', 2, 2, 1, A, 2, B, 2 ); +* // B => [ 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 0.0, 0.0 ] +*/ +function ctriu( order, M, N, k, A, LDA, B, LDB ) { + var isrm; + var sa1; + var sa2; + var sb1; + var sb2; + var s; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + isrm = isRowMajor( order ); + if ( isrm ) { + s = N; + } else { + s = M; + } + if ( LDA < max( 1, s ) ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); + } + if ( LDB < max( 1, s ) ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDB ) ); + } + if ( isrm ) { + sa1 = LDA; + sa2 = 1; + sb1 = LDB; + sb2 = 1; + } else { // order === 'column-major' + sa1 = 1; + sa2 = LDA; + sb1 = 1; + sb2 = LDB; + } + return base( M, N, k, A, sa1, sa2, 0, B, sb1, sb2, 0 ); +} + + +// EXPORTS // + +module.exports = ctriu; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/ctriu.native.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/ctriu.native.js new file mode 100644 index 000000000000..d4974aed6e34 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/ctriu.native.js @@ -0,0 +1,86 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +var resolveOrder = require( '@stdlib/blas/base/layout-resolve-enum' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var format = require( '@stdlib/string/format' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Copies the upper triangular part of a single-precision floating-point matrix `A` to another matrix `B`. +* +* @param {string} order - storage layout of `A` and `B` +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {integer} k - diagonal below which to ignore +* @param {Complex64Array} A - input matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Complex64Array} B - output matrix +* @param {PositiveInteger} LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} sixth argument must be a valid stride +* @throws {RangeError} eighth argument must be a valid stride +* @returns {Complex64Array} `B` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctriu( 'row-major', 2, 2, 0, A, 2, B, 2 ); +* // B => [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ] +*/ +function ctriu( order, M, N, k, A, LDA, B, LDB ) { + var viewA; + var viewB; + var s; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( isRowMajor( order ) ) { + s = N; + } else { + s = M; + } + if ( LDA < max( 1, s ) ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); + } + if ( LDB < max( 1, s ) ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDB ) ); + } + viewA = reinterpret( A, 0 ); + viewB = reinterpret( B, 0 ); + addon( resolveOrder( order ), M, N, k, viewA, LDA, viewB, LDB ); + return B; +} + + +// EXPORTS // + +module.exports = ctriu; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/index.js new file mode 100644 index 000000000000..697d266e463d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/index.js @@ -0,0 +1,70 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +/** +* Copy the upper triangular part of a single-precision complex floating-point matrix `A` to another matrix `B`. +* +* @module @stdlib/blas/ext/base/ctriu +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var ctriu = require( '@stdlib/blas/ext/base/ctriu' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctriu( 'row-major', 2, 2, 0, A, 2, B, 2 ); +* // B => [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ] +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var ctriu = require( '@stdlib/blas/ext/base/ctriu' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.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 ctriu; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + ctriu = main; +} else { + ctriu = tmp; +} + + +// EXPORTS // + +module.exports = ctriu; + +// exports: { "ndarray": "ctriu.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/main.js new file mode 100644 index 000000000000..d7c0f3f69c1a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 ctriu = require( './ctriu.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( ctriu, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = ctriu; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/native.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/native.js new file mode 100644 index 000000000000..8e7f3e5068ac --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/native.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 main = require( './ctriu.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( main, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/ndarray.js new file mode 100644 index 000000000000..7ce993af4395 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/ndarray.js @@ -0,0 +1,69 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 // + +/** +* Copies the upper triangular part of a single-precision complex floating-point matrix `A` to another matrix `B` using alternative indexing semantics. +* +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {integer} k - diagonal below which to ignore +* @param {Complex64Array} 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` +* @param {Complex64Array} B - output matrix +* @param {integer} strideB1 - stride of the first dimension of `B` +* @param {integer} strideB2 - stride of the second dimension of `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` +* @returns {Complex64Array} `B` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctriu( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ] +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctriu( 2, 2, -1, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] +*/ +function ctriu( M, N, k, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-len, max-params + return base( M, N, k, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = ctriu; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/ndarray.native.js new file mode 100644 index 000000000000..65620378a311 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/ndarray.native.js @@ -0,0 +1,64 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 reinterpret = require( '@stdlib/strided/base/reinterpret-complex64' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Copies the upper triangular part of a single-precision floating-point matrix `A` to another matrix `B` using alternative indexing semantics. +* +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {integer} k - diagonal below which to ignore +* @param {Complex64Array} 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` +* @param {Complex64Array} B - output matrix +* @param {integer} strideB1 - stride of the first dimension of `B` +* @param {integer} strideB2 - stride of the second dimension of `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` +* @returns {Complex64Array} `B` +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* +* var A = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var B = new Complex64Array( 4 ); +* +* ctriu( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ] +*/ +function ctriu( M, N, k, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-len, max-params + var viewA = reinterpret( A, 0 ); + var viewB = reinterpret( B, 0 ); + addon.ndarray( M, N, k, viewA, strideA1, strideA2, offsetA, viewB, strideB1, strideB2, offsetB ); // eslint-disable-line max-len + return B; +} + + +// EXPORTS // + +module.exports = ctriu; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/ctriu/manifest.json new file mode 100644 index 000000000000..e6bb20543ae9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/manifest.json @@ -0,0 +1,82 @@ +{ + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-strided-complex64array2d", + "@stdlib/complex/float32/ctor" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/complex/float32/ctor" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/complex/float32/ctor" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/package.json b/lib/node_modules/@stdlib/blas/ext/base/ctriu/package.json new file mode 100644 index 000000000000..398d3667feaa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/package.json @@ -0,0 +1,79 @@ +{ + "name": "@stdlib/blas/ext/base/ctriu", + "version": "0.0.0", + "description": "Copy the upper triangular part of a single-precision complex floating-point matrix A to another matrix B.", + "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", + "browser": "./lib/main.js", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "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", + "blas", + "extended", + "ext", + "linear", + "algebra", + "matrix", + "triangular", + "triangle", + "upper", + "triu", + "ctriu", + "copy", + "array", + "ndarray", + "complex64", + "complex", + "single", + "complex64array" + ], + "__stdlib__": { + "wasm": false + } +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/src/Makefile b/lib/node_modules/@stdlib/blas/ext/base/ctriu/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/ctriu/src/addon.c new file mode 100644 index 000000000000..b59ffe83c69d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/src/addon.c @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +#include "stdlib/blas/ext/base/ctriu.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_int32.h" +#include "stdlib/napi/argv_strided_complex64array2d.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + CBLAS_INT sa1; + CBLAS_INT sa2; + CBLAS_INT sb1; + CBLAS_INT sb2; + + STDLIB_NAPI_ARGV( env, info, argv, argc, 8 ); + + STDLIB_NAPI_ARGV_INT32( env, layout, argv, 0 ); + + STDLIB_NAPI_ARGV_INT64( env, M, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, k, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, LDA, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, LDB, argv, 7 ); + + if ( layout == CblasColMajor ) { + sa1 = 1; + sa2 = LDA; + sb1 = 1; + sb2 = LDB; + } else { // layout == CblasRowMajor + sa1 = LDA; + sa2 = 1; + sb1 = LDB; + sb2 = 1; + } + STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY2D( env, A, M, N, sa1, sa2, argv, 4 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY2D( env, B, M, N, sb1, sb2, argv, 6 ); + + API_SUFFIX(stdlib_strided_ctriu)( layout, M, N, k, (stdlib_complex64_t *)A, LDA, (stdlib_complex64_t *)B, LDB ); + + return NULL; +} + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon_method( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 11 ); + + STDLIB_NAPI_ARGV_INT64( env, M, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, k, argv, 2 ); + + STDLIB_NAPI_ARGV_INT64( env, strideA1, argv, 4 ); + STDLIB_NAPI_ARGV_INT64( env, strideA2, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, offsetA, argv, 6 ); + + STDLIB_NAPI_ARGV_INT64( env, strideB1, argv, 8 ); + STDLIB_NAPI_ARGV_INT64( env, strideB2, argv, 9 ); + STDLIB_NAPI_ARGV_INT64( env, offsetB, argv, 10 ); + + STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY2D( env, A, M, N, strideA1, strideA2, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX64ARRAY2D( env, B, M, N, strideB1, strideB2, argv, 7 ); + + API_SUFFIX(stdlib_strided_ctriu_ndarray)( M, N, k, (stdlib_complex64_t *)A, strideA1, strideA2, offsetA, (stdlib_complex64_t *)B, strideB1, strideB2, offsetB ); + + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ctriu/src/main.c new file mode 100644 index 000000000000..c8e467dd338d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/src/main.c @@ -0,0 +1,108 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +#include "stdlib/blas/ext/base/ctriu.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/ndarray/base/assert/is_row_major.h" +#include "stdlib/complex/float32/ctor.h" +#include + +// Define macros for computing the minimum and maximum values: +#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) +#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y)) + +/** +* Copies the upper triangular part of a single-precision complex floating-point matrix `A` to another matrix `B`. +* +* @param layout storage layout +* @param M number of rows in the matrix `A` +* @param N number of columns in the matrix `A` +* @param k diagonal below which to ignore +* @param A input matrix +* @param LDA stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param B output matrix +* @param LDB stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) +*/ +void API_SUFFIX(stdlib_strided_ctriu)( const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N, const CBLAS_INT k, const stdlib_complex64_t *A, const CBLAS_INT LDA, stdlib_complex64_t *B, const CBLAS_INT LDB ) { + CBLAS_INT sa1; + CBLAS_INT sa2; + CBLAS_INT sb1; + CBLAS_INT sb2; + + if ( layout == CblasColMajor ) { + sa1 = 1; + sa2 = LDA; + sb1 = 1; + sb2 = LDB; + } else { // layout == CblasRowMajor + sa1 = LDA; + sa2 = 1; + sb1 = LDB; + sb2 = 1; + } + API_SUFFIX(stdlib_strided_ctriu_ndarray)( M, N, k, A, sa1, sa2, 0, B, sb1, sb2, 0 ); +} + +/** +* Copies the upper triangular part of a single-precision complex floating-point matrix `A` to another matrix `B` using alternative indexing semantics. +* +* @param M number of rows in the matrix `A` +* @param N number of columns in the matrix `A` +* @param k diagonal below which to ignore +* @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` +* @param B output matrix +* @param strideB1 stride of the first dimension of `B` +* @param strideB2 stride of the second dimension of `B` +* @param offsetB starting index for `B` +*/ +void API_SUFFIX(stdlib_strided_ctriu_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const CBLAS_INT k, const stdlib_complex64_t *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, stdlib_complex64_t *B, const CBLAS_INT strideB1, const CBLAS_INT strideB2, const CBLAS_INT offsetB ) { + int64_t sa[ 2 ]; + CBLAS_INT ia; + CBLAS_INT ib; + CBLAS_INT i0; + CBLAS_INT i1; + + ia = offsetA; + ib = offsetB; + + sa[ 0 ] = strideA1; + sa[ 1 ] = strideA2; + if ( stdlib_ndarray_is_row_major( 2, sa ) ) { + // Copy row-by-row in order to ensure cache-optimal traversal... + for ( i1 = 0; i1 < M; i1++ ) { + for ( i0 = MAX( 0, i1+k ); i0 < N; i0++ ) { + B[ ib+(i0*strideB2) ] = A[ ia+(i0*strideA2) ]; + } + ia += strideA1; + ib += strideB1; + } + return; + } + // Copy column-by-column in order to ensure cache-optimal traversal... + for ( i1 = 0; i1 < N; i1++ ) { + for ( i0 = 0; i0 <= MIN( i1-k, M-1 ); i0++ ) { + B[ ib+(i0*strideB1) ] = A[ ia+(i0*strideA1) ]; + } + ia += strideA2; + ib += strideB2; + } + return; +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ctriu.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ctriu.js new file mode 100644 index 000000000000..d10825706b3b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ctriu.js @@ -0,0 +1,376 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 Complex64Array = require( '@stdlib/array/complex64' ); +var ctriu = require( './../lib/ctriu' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ctriu, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( ctriu.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 i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctriu( value, 2, 2, 0, A, 2, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided a sixth argument which is not a valid LDA value (row-major)', function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctriu( 'row-major', 2, 2, 0, A, value, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an eighth argument which is not a valid LDB value (row-major)', function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctriu( 'row-major', 2, 2, 0, A, 2, B, value ); + }; + } +}); + +tape( 'the function throws an error if provided a sixth argument which is not a valid LDA value (column-major)', function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctriu( 'column-major', 2, 2, 0, A, value, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an eighth argument which is not a valid LDB value (column-major)', function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctriu( 'column-major', 2, 2, 0, A, 2, B, value ); + }; + } +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k=0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 'row-major', 3, 3, 0, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 9.0, 9.0 ] ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k>0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 'row-major', 3, 3, 1, A, 3, B, 3 ); + + expected = new Complex64Array( [ 0.0, 0.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 0.0, 0.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k<0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 'row-major', 3, 3, -1, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 0.0, 0.0, 8.0, 8.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (column-major, k=0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 'column-major', 3, 3, 0, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 0.0, 0.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (column-major, k<0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 'column-major', 3, 3, -1, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (column-major, k>0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 'column-major', 3, 3, 1, A, 3, B, 3 ); + + expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 6.0, 6.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (row-major)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctriu( 'row-major', 2, 3, 0, A, 3, B, 3 ); + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0, 6.0, 6.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctriu( 'row-major', 3, 2, 0, A, 2, B, 2 ); + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0, 0.0, 0.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports non-square matrices (column-major)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 2.0, 2.0, 5.0, 5.0, 3.0, 3.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctriu( 'column-major', 2, 3, 0, A, 2, B, 2 ); + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 3.0, 3.0, 6.0, 6.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 5.0, 5.0, 2.0, 2.0, 4.0, 4.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctriu( 'column-major', 3, 2, 0, A, 3, B, 3 ); + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 4.0, 4.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a leading dimension greater than the number of rows/columns (padded matrix)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 9.0, 9.0, 3.0, 3.0, 4.0, 4.0, 9.0, 9.0 ] ); + B = new Complex64Array( 6 ); + out = ctriu( 'row-major', 2, 2, 0, A, 3, B, 3 ); + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 9.0, 9.0, 2.0, 2.0, 4.0, 4.0, 9.0, 9.0 ] ); + B = new Complex64Array( 6 ); + out = ctriu( 'column-major', 2, 2, 0, A, 3, B, 3 ); + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 4.0, 4.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function leaves elements outside of the copied region unchanged', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( [ -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0 ] ); + + out = ctriu( 'row-major', 3, 3, 0, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, -1.0, -1.0, 5.0, 5.0, 6.0, 6.0, -1.0, -1.0, -1.0, -1.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'when `k` is greater than or equal to `N`, the function copies nothing', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + out = ctriu( 'row-major', 2, 2, 2, A, 2, B, 2 ); + + expected = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'when `k` is sufficiently negative, the function copies the entire matrix', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( 4 ); + + out = ctriu( 'row-major', 2, 2, -2, A, 2, B, 2 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function leaves `B` unchanged when `M` or `N` is equal to zero', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + expected = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + out = ctriu( 'row-major', 0, 2, 0, A, 2, B, 2 ); + t.deepEqual( out, expected, 'returns expected value' ); + + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + out = ctriu( 'row-major', 2, 0, 0, A, 2, B, 2 ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ctriu.native.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ctriu.native.js new file mode 100644 index 000000000000..5c7d11d03711 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ctriu.native.js @@ -0,0 +1,385 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var ctriu = tryRequire( resolve( __dirname, './../lib/ctriu.native.js' ) ); +var opts = { + 'skip': ( ctriu instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ctriu, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', opts, function test( t ) { + t.strictEqual( ctriu.length, 8, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', opts, function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctriu( value, 2, 2, 0, A, 2, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided a sixth argument which is not a valid LDA value (row-major)', opts, function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctriu( 'row-major', 2, 2, 0, A, value, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an eighth argument which is not a valid LDB value (row-major)', opts, function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctriu( 'row-major', 2, 2, 0, A, 2, B, value ); + }; + } +}); + +tape( 'the function throws an error if provided a sixth argument which is not a valid LDA value (column-major)', opts, function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctriu( 'column-major', 2, 2, 0, A, value, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an eighth argument which is not a valid LDB value (column-major)', opts, function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + 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() { + var A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + var B = new Complex64Array( 4 ); + ctriu( 'column-major', 2, 2, 0, A, 2, B, value ); + }; + } +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k=0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 'row-major', 3, 3, 0, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 9.0, 9.0 ] ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k>0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 'row-major', 3, 3, 1, A, 3, B, 3 ); + + expected = new Complex64Array( [ 0.0, 0.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 0.0, 0.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k<0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 'row-major', 3, 3, -1, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 0.0, 0.0, 8.0, 8.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (column-major, k=0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 'column-major', 3, 3, 0, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 0.0, 0.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (column-major, k<0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 'column-major', 3, 3, -1, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (column-major, k>0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 'column-major', 3, 3, 1, A, 3, B, 3 ); + + expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 6.0, 6.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (row-major)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctriu( 'row-major', 2, 3, 0, A, 3, B, 3 ); + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0, 6.0, 6.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctriu( 'row-major', 3, 2, 0, A, 2, B, 2 ); + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0, 0.0, 0.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports non-square matrices (column-major)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 2.0, 2.0, 5.0, 5.0, 3.0, 3.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctriu( 'column-major', 2, 3, 0, A, 2, B, 2 ); + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 3.0, 3.0, 6.0, 6.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 5.0, 5.0, 2.0, 2.0, 4.0, 4.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctriu( 'column-major', 3, 2, 0, A, 3, B, 3 ); + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 4.0, 4.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a leading dimension greater than the number of rows/columns (padded matrix)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 9.0, 9.0, 3.0, 3.0, 4.0, 4.0, 9.0, 9.0 ] ); + B = new Complex64Array( 6 ); + out = ctriu( 'row-major', 2, 2, 0, A, 3, B, 3 ); + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 9.0, 9.0, 2.0, 2.0, 4.0, 4.0, 9.0, 9.0 ] ); + B = new Complex64Array( 6 ); + out = ctriu( 'column-major', 2, 2, 0, A, 3, B, 3 ); + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 4.0, 4.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function leaves elements outside of the copied region unchanged', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( [ -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0 ] ); + + out = ctriu( 'row-major', 3, 3, 0, A, 3, B, 3 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, -1.0, -1.0, 5.0, 5.0, 6.0, 6.0, -1.0, -1.0, -1.0, -1.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'when `k` is greater than or equal to `N`, the function copies nothing', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + out = ctriu( 'row-major', 2, 2, 2, A, 2, B, 2 ); + + expected = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'when `k` is sufficiently negative, the function copies the entire matrix', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( 4 ); + + out = ctriu( 'row-major', 2, 2, -2, A, 2, B, 2 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function leaves `B` unchanged when `M` or `N` is equal to zero', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + expected = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + out = ctriu( 'row-major', 0, 2, 0, A, 2, B, 2 ); + t.deepEqual( out, expected, 'returns expected value' ); + + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + out = ctriu( 'row-major', 2, 0, 0, A, 2, B, 2 ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.js new file mode 100644 index 000000000000..ddc4096fb7b9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 ctriu = 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 ctriu, '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 ctriu.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 ctriu = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( ctriu, mock, 'returns native implementation' ); + 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 ctriu; + var main; + + main = require( './../lib/main.js' ); + + ctriu = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( ctriu, main, 'returns JavaScript implementation' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ndarray.js new file mode 100644 index 000000000000..4aa9dda8488d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ndarray.js @@ -0,0 +1,296 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 Complex64Array = require( '@stdlib/array/complex64' ); +var ctriu = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ctriu, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', function test( t ) { + t.strictEqual( ctriu.length, 11, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k=0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 3, 3, 0, A, 3, 1, 0, B, 3, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 9.0, 9.0 ] ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k>0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 3, 3, 1, A, 3, 1, 0, B, 3, 1, 0 ); + + expected = new Complex64Array( [ 0.0, 0.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 0.0, 0.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k<0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 3, 3, -1, A, 3, 1, 0, B, 3, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 0.0, 0.0, 8.0, 8.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (column-major, k=0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 3, 3, 0, A, 1, 3, 0, B, 1, 3, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 0.0, 0.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (column-major, k<0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 3, 3, -1, A, 1, 3, 0, B, 1, 3, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (column-major, k>0)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 3, 3, 1, A, 1, 3, 0, B, 1, 3, 0 ); + + expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 6.0, 6.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (row-major)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctriu( 2, 3, 0, A, 3, 1, 0, B, 3, 1, 0 ); + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0, 6.0, 6.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (column-major)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 5.0, 5.0, 2.0, 2.0, 4.0, 4.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctriu( 3, 2, 0, A, 1, 3, 0, B, 1, 3, 0 ); + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 4.0, 4.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `A` offset', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 0.0, 0.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0 ] ); + B = new Complex64Array( 4 ); + + out = ctriu( 2, 2, 0, A, 2, 1, 1, B, 2, 1, 0 ); + + expected = new Complex64Array( [ 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `B` offset', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( 6 ); + + out = ctriu( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 2 ); + + expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 2.0, 2.0, 1.0, 1.0, 4.0, 4.0, 3.0, 3.0 ] ); + B = new Complex64Array( 4 ); + + out = ctriu( 2, 2, 0, A, 2, -1, 1, B, 2, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function leaves elements outside of the copied region unchanged', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( [ -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0 ] ); + + out = ctriu( 3, 3, 0, A, 3, 1, 0, B, 3, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, -1.0, -1.0, 5.0, 5.0, 6.0, 6.0, -1.0, -1.0, -1.0, -1.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'when `k` is greater than or equal to `N`, the function copies nothing', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + out = ctriu( 2, 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); + + expected = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'when `k` is sufficiently negative, the function copies the entire matrix', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( 4 ); + + out = ctriu( 2, 2, -2, A, 2, 1, 0, B, 2, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function leaves `B` unchanged when `M` or `N` is equal to zero', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + expected = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + out = ctriu( 0, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); + t.deepEqual( out, expected, 'returns expected value' ); + + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + out = ctriu( 2, 0, 0, A, 2, 1, 0, B, 2, 1, 0 ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (non-unit strides and offsets on both `A` and `B`)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 9.0, 9.0, 1.0, 1.0, 9.0, 9.0, 2.0, 2.0, 9.0, 9.0, 3.0, 3.0, 9.0, 9.0, 4.0, 4.0 ] ); + B = new Complex64Array( 8 ); + + out = ctriu( 2, 2, 0, A, 4, 2, 1, B, 4, 2, 1 ); + + expected = new Complex64Array( [ 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ndarray.native.js new file mode 100644 index 000000000000..303cf3155f01 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ndarray.native.js @@ -0,0 +1,310 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var ctriu = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( ctriu instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ctriu, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', opts, function test( t ) { + t.strictEqual( ctriu.length, 11, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k=0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 3, 3, 0, A, 3, 1, 0, B, 3, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 9.0, 9.0 ] ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k>0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 3, 3, 1, A, 3, 1, 0, B, 3, 1, 0 ); + + expected = new Complex64Array( [ 0.0, 0.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 0.0, 0.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k<0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 3, 3, -1, A, 3, 1, 0, B, 3, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 0.0, 0.0, 8.0, 8.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (column-major, k=0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 3, 3, 0, A, 1, 3, 0, B, 1, 3, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 0.0, 0.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (column-major, k<0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 3, 3, -1, A, 1, 3, 0, B, 1, 3, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies the upper triangular part of `A` to `B` (column-major, k>0)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 7.0, 7.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); + B = new Complex64Array( 9 ); + + out = ctriu( 3, 3, 1, A, 1, 3, 0, B, 1, 3, 0 ); + + expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 6.0, 6.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (row-major)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + // 2x3 row-major + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctriu( 2, 3, 0, A, 3, 1, 0, B, 3, 1, 0 ); + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0, 6.0, 6.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports non-square matrices (column-major)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + // 3x2 column-major + A = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 5.0, 5.0, 2.0, 2.0, 4.0, 4.0, 6.0, 6.0 ] ); + B = new Complex64Array( 6 ); + out = ctriu( 3, 2, 0, A, 1, 3, 0, B, 1, 3, 0 ); + expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 4.0, 4.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `A` offset', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + // 2x2 with A offset=1 (start from 2nd element) + A = new Complex64Array( [ 0.0, 0.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0 ] ); + B = new Complex64Array( 4 ); + + out = ctriu( 2, 2, 0, A, 2, 1, 1, B, 2, 1, 0 ); + + expected = new Complex64Array( [ 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `B` offset', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + // 2x2 with B offset=2 (start writing from 3rd element) + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( 6 ); + + out = ctriu( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 2 ); + + expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + // 2x2 row-major with negative stride for columns (reversed columns) + A = new Complex64Array( [ 2.0, 2.0, 1.0, 1.0, 4.0, 4.0, 3.0, 3.0 ] ); + B = new Complex64Array( 4 ); + + out = ctriu( 2, 2, 0, A, 2, -1, 1, B, 2, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function leaves elements outside of the copied region unchanged', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0, 9.0 ] ); + B = new Complex64Array( [ -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0 ] ); + + out = ctriu( 3, 3, 0, A, 3, 1, 0, B, 3, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, -1.0, -1.0, 5.0, 5.0, 6.0, 6.0, -1.0, -1.0, -1.0, -1.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'when `k` is greater than or equal to `N`, the function copies nothing', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + out = ctriu( 2, 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); + + expected = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'when `k` is sufficiently negative, the function copies the entire matrix', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + B = new Complex64Array( 4 ); + + out = ctriu( 2, 2, -2, A, 2, 1, 0, B, 2, 1, 0 ); + + expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function leaves `B` unchanged when `M` or `N` is equal to zero', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); + expected = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + out = ctriu( 0, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); + t.deepEqual( out, expected, 'returns expected value' ); + + B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); + out = ctriu( 2, 0, 0, A, 2, 1, 0, B, 2, 1, 0 ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (non-unit strides and offsets on both `A` and `B`)', opts, function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Complex64Array( [ 9.0, 9.0, 1.0, 1.0, 9.0, 9.0, 2.0, 2.0, 9.0, 9.0, 3.0, 3.0, 9.0, 9.0, 4.0, 4.0 ] ); + B = new Complex64Array( 8 ); + + out = ctriu( 2, 2, 0, A, 4, 2, 1, B, 4, 2, 1 ); + + expected = new Complex64Array( [ 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); From 4687d4f00a22080e8bc96d5fce2aa5ed8569858a Mon Sep 17 00:00:00 2001 From: Kaustubh Patange Date: Tue, 4 Aug 2026 02:55:05 +0530 Subject: [PATCH 2/5] Apply suggestions from code review Co-authored-by: Kaustubh Patange Signed-off-by: Kaustubh Patange --- .../@stdlib/blas/ext/base/ctriu/README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/README.md b/lib/node_modules/@stdlib/blas/ext/base/ctriu/README.md index 7df6c51b66d8..a7c03fd19f0c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ctriu/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/README.md @@ -157,6 +157,7 @@ ctriu.ndarray( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 2 ); ```javascript var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); var uniform = require( '@stdlib/random/array/discrete-uniform' ); +var Complex64Array = require( '@stdlib/array/complex64' ); var numel = require( '@stdlib/ndarray/base/numel' ); var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); var ctriu = require( '@stdlib/blas/ext/base/ctriu' ); @@ -167,14 +168,14 @@ var strides = shape2strides( shape, order ); var N = numel( shape ); -var A = uniform( N, -10, 10, { - 'dtype': 'complex64' -}); +var A = new Complex64Array( uniform( N*2, -10, 10, { + 'dtype': 'float32' +}).buffer ); console.log( ndarray2array( A, shape, strides, 0, order ) ); -var B = uniform( N, -10, 10, { - 'dtype': 'complex64' -}); +var B = new Complex64Array( uniform( N*2, -10, 10, { + 'dtype': 'float32' +}).buffer ); console.log( ndarray2array( B, shape, strides, 0, order ) ); ctriu( order, shape[ 0 ], shape[ 1 ], 0, A, strides[ 0 ], B, strides[ 0 ] ); From d1ce376b21aa253982f48b4082b5e50b6aa089f5 Mon Sep 17 00:00:00 2001 From: kaustubh Date: Tue, 4 Aug 2026 11:19:39 +0530 Subject: [PATCH 3/5] fix: apply suggestions from code review --- 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_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - 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/blas/ext/base/ctriu/README.md | 9 +++-- .../ext/base/ctriu/benchmark/benchmark.js | 4 +-- .../base/ctriu/benchmark/benchmark.native.js | 4 +-- .../base/ctriu/benchmark/benchmark.ndarray.js | 4 +-- .../benchmark/benchmark.ndarray.native.js | 4 +-- .../@stdlib/blas/ext/base/ctriu/docs/repl.txt | 8 ++--- .../blas/ext/base/ctriu/docs/types/test.ts | 1 + .../blas/ext/base/ctriu/examples/index.js | 9 +++-- .../@stdlib/blas/ext/base/ctriu/lib/base.js | 14 +++++--- .../base/ctriu/test/test.ndarray.native.js | 35 ++++++++++--------- 10 files changed, 49 insertions(+), 43 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/README.md b/lib/node_modules/@stdlib/blas/ext/base/ctriu/README.md index a7c03fd19f0c..1befdb602dff 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ctriu/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/README.md @@ -168,14 +168,13 @@ var strides = shape2strides( shape, order ); var N = numel( shape ); -var A = new Complex64Array( uniform( N*2, -10, 10, { +var opts = { 'dtype': 'float32' -}).buffer ); +}; +var A = new Complex64Array( uniform( N*2, -10, 10, opts ) ); console.log( ndarray2array( A, shape, strides, 0, order ) ); -var B = new Complex64Array( uniform( N*2, -10, 10, { - 'dtype': 'float32' -}).buffer ); +var B = new Complex64Array( uniform( N*2, -10, 10, opts ) ); console.log( ndarray2array( B, shape, strides, 0, order ) ); ctriu( order, shape[ 0 ], shape[ 1 ], 0, A, strides[ 0 ], B, strides[ 0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.js index ba10fefeaf12..c1469d34d586 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.js @@ -67,8 +67,8 @@ function createBenchmark( order, N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { z = ctriu( order, N, N, 0, A, N, B, N ); - if ( isnanf( realf( z.get( i%z.length ) ) ) ) { - b.fail( 'should not return NaN' ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an array' ); } } b.toc(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.native.js index 9e80589232d9..ddcadab71fc2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.native.js @@ -72,8 +72,8 @@ function createBenchmark( order, N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { z = ctriu( order, N, N, 0, A, N, B, N ); - if ( isnanf( realf( z.get( i%z.length ) ) ) ) { - b.fail( 'should not return NaN' ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an array' ); } } b.toc(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.ndarray.js index 0dfafb3a6ebe..1a6b909f7502 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.ndarray.js @@ -81,8 +81,8 @@ function createBenchmark( order, N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { z = ctriu( N, N, 0, A, sa1, sa2, 0, B, sa1, sa2, 0 ); - if ( isnanf( realf( z.get( i%z.length ) ) ) ) { - b.fail( 'should not return NaN' ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an array' ); } } b.toc(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.ndarray.native.js index 870fa92cb208..7e4e9fd5522f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/benchmark/benchmark.ndarray.native.js @@ -86,8 +86,8 @@ function createBenchmark( order, N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { z = ctriu( N, N, 0, A, sa1, sa2, 0, B, sa1, sa2, 0 ); - if ( isnanf( realf( z.get( i%z.length ) ) ) ) { - b.fail( 'should not return NaN' ); + if ( typeof z !== 'object' ) { + b.fail( 'should return an array' ); } } b.toc(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/repl.txt index b8b95538d050..7bf788b75ad8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( order, M, N, k, A, LDA, B, LDB ) - Copies the upper triangular part of a single-precision complex - floating-point matrix `A` to another matrix `B`. + Copies the upper triangular part of a single-precision complex floating- + point matrix `A` to another matrix `B`. Indexing is relative to the first index. To introduce an offset, use typed array views. @@ -54,8 +54,8 @@ {{alias}}.ndarray( M, N, k, A, sa1, sa2, oa, B, sb1, sb2, ob ) - Copies the upper triangular part of a single-precision complex - floating-point matrix `A` to another matrix `B` using alternative indexing + Copies the upper triangular part of a single-precision complex floating- + point matrix `A` to another matrix `B` using alternative indexing semantics. While typed array views mandate a view offset based on the underlying diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/types/test.ts index b5a2c3aacd88..f5712d9a825e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/types/test.ts @@ -16,6 +16,7 @@ * limitations under the License. */ +import Complex64Array = require( '@stdlib/array/complex64' ); import ctriu = require( './index' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/examples/index.js index ead551c2d245..79bbb5a7d8fb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ctriu/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/examples/index.js @@ -31,14 +31,13 @@ var strides = shape2strides( shape, order ); var N = numel( shape ); -var A = new Complex64Array( uniform( N*2, -10, 10, { +var opts = { 'dtype': 'float32' -}).buffer ); +}; +var A = new Complex64Array( uniform( N*2, -10, 10, opts ) ); console.log( ndarray2array( A, shape, strides, 0, order ) ); -var B = new Complex64Array( uniform( N*2, -10, 10, { - 'dtype': 'float32' -}).buffer ); +var B = new Complex64Array( uniform( N*2, -10, 10, opts ) ); console.log( ndarray2array( B, shape, strides, 0, order ) ); ctriu( order, shape[ 0 ], shape[ 1 ], 0, A, strides[ 0 ], B, strides[ 0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/base.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/base.js index 19badbdf455c..14c819265e29 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/base.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/lib/base.js @@ -74,6 +74,8 @@ function ctriu( M, N, k, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, var sb2; var ia; var ib; + var ja; + var jb; var i0; var i1; @@ -89,8 +91,10 @@ function ctriu( M, N, k, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, if ( isRowMajor( [ strideA1, strideA2 ] ) ) { for ( i1 = 0; i1 < M; i1++ ) { for ( i0 = max( 0, i1+k ); i0 < N; i0++ ) { - viewB[ ib+(i0*sb2) ] = viewA[ ia+(i0*sa2) ]; - viewB[ ib+(i0*sb2)+1 ] = viewA[ ia+(i0*sa2)+1 ]; + ja = ia + ( i0*sa2 ); + jb = ib + ( i0*sb2 ); + viewB[ jb ] = viewA[ ja ]; + viewB[ jb+1 ] = viewA[ ja+1 ]; } ia += sa1; ib += sb1; @@ -99,8 +103,10 @@ function ctriu( M, N, k, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, } for ( i1 = 0; i1 < N; i1++ ) { for ( i0 = 0; i0 <= min( i1-k, M-1 ); i0++ ) { - viewB[ ib+(i0*sb1) ] = viewA[ ia+(i0*sa1) ]; - viewB[ ib+(i0*sb1)+1 ] = viewA[ ia+(i0*sa1)+1 ]; + ja = ia + ( i0*sa1 ); + jb = ib + ( i0*sb1 ); + viewB[ jb ] = viewA[ ja ]; + viewB[ jb+1 ] = viewA[ ja+1 ]; } ia += sa2; ib += sb2; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ndarray.native.js index 303cf3155f01..ac49acbbc7d3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ndarray.native.js @@ -22,6 +22,7 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); var Complex64Array = require( '@stdlib/array/complex64' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -60,7 +61,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 9.0, 9.0 ] ); t.strictEqual( out, B, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -76,7 +77,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k out = ctriu( 3, 3, 1, A, 3, 1, 0, B, 3, 1, 0 ); expected = new Complex64Array( [ 0.0, 0.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 0.0, 0.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -92,7 +93,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k out = ctriu( 3, 3, -1, A, 3, 1, 0, B, 3, 1, 0 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 0.0, 0.0, 8.0, 8.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -108,7 +109,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (column-major out = ctriu( 3, 3, 0, A, 1, 3, 0, B, 1, 3, 0 ); expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 0.0, 0.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -124,7 +125,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (column-major out = ctriu( 3, 3, -1, A, 1, 3, 0, B, 1, 3, 0 ); expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -140,7 +141,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (column-major out = ctriu( 3, 3, 1, A, 1, 3, 0, B, 1, 3, 0 ); expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 6.0, 6.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -155,7 +156,7 @@ tape( 'the function supports non-square matrices (row-major)', opts, function te B = new Complex64Array( 6 ); out = ctriu( 2, 3, 0, A, 3, 1, 0, B, 3, 1, 0 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0, 6.0, 6.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -170,7 +171,7 @@ tape( 'the function supports non-square matrices (column-major)', opts, function B = new Complex64Array( 6 ); out = ctriu( 3, 2, 0, A, 1, 3, 0, B, 1, 3, 0 ); expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 4.0, 4.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -187,7 +188,7 @@ tape( 'the function supports an `A` offset', opts, function test( t ) { out = ctriu( 2, 2, 0, A, 2, 1, 1, B, 2, 1, 0 ); expected = new Complex64Array( [ 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -204,7 +205,7 @@ tape( 'the function supports a `B` offset', opts, function test( t ) { out = ctriu( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 2 ); expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -221,7 +222,7 @@ tape( 'the function supports negative strides', opts, function test( t ) { out = ctriu( 2, 2, 0, A, 2, -1, 1, B, 2, 1, 0 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -237,7 +238,7 @@ tape( 'the function leaves elements outside of the copied region unchanged', opt out = ctriu( 3, 3, 0, A, 3, 1, 0, B, 3, 1, 0 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, -1.0, -1.0, 5.0, 5.0, 6.0, 6.0, -1.0, -1.0, -1.0, -1.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -253,7 +254,7 @@ tape( 'when `k` is greater than or equal to `N`, the function copies nothing', o out = ctriu( 2, 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); expected = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -269,7 +270,7 @@ tape( 'when `k` is sufficiently negative, the function copies the entire matrix' out = ctriu( 2, 2, -2, A, 2, 1, 0, B, 2, 1, 0 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -284,11 +285,11 @@ tape( 'the function leaves `B` unchanged when `M` or `N` is equal to zero', opts B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); out = ctriu( 0, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); out = ctriu( 2, 0, 0, A, 2, 1, 0, B, 2, 1, 0 ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -305,6 +306,6 @@ tape( 'the function supports complex access patterns (non-unit strides and offse out = ctriu( 2, 2, 0, A, 4, 2, 1, B, 4, 2, 1 ); expected = new Complex64Array( [ 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); From 3a27b99edfd063f801846892ef7992235b6a0f5e Mon Sep 17 00:00:00 2001 From: kaustubh Date: Tue, 4 Aug 2026 11:21:35 +0530 Subject: [PATCH 4/5] fix: apply suggestions from code review --- 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_pkg_readmes status: na - task: lint_markdown_docs status: na - 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../blas/ext/base/ctriu/test/test.ctriu.js | 35 ++++++++++--------- .../ext/base/ctriu/test/test.ctriu.native.js | 35 ++++++++++--------- .../blas/ext/base/ctriu/test/test.ndarray.js | 35 ++++++++++--------- 3 files changed, 54 insertions(+), 51 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ctriu.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ctriu.js index d10825706b3b..ff08f398f17e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ctriu.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ctriu.js @@ -21,6 +21,7 @@ // MODULES // var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); var Complex64Array = require( '@stdlib/array/complex64' ); var ctriu = require( './../lib/ctriu' ); @@ -160,7 +161,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 9.0, 9.0 ] ); t.strictEqual( out, B, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -176,7 +177,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k out = ctriu( 'row-major', 3, 3, 1, A, 3, B, 3 ); expected = new Complex64Array( [ 0.0, 0.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 0.0, 0.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -192,7 +193,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k out = ctriu( 'row-major', 3, 3, -1, A, 3, B, 3 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 0.0, 0.0, 8.0, 8.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -208,7 +209,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (column-major out = ctriu( 'column-major', 3, 3, 0, A, 3, B, 3 ); expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 0.0, 0.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -224,7 +225,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (column-major out = ctriu( 'column-major', 3, 3, -1, A, 3, B, 3 ); expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -240,7 +241,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (column-major out = ctriu( 'column-major', 3, 3, 1, A, 3, B, 3 ); expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 6.0, 6.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -254,13 +255,13 @@ tape( 'the function supports non-square matrices (row-major)', function test( t B = new Complex64Array( 6 ); out = ctriu( 'row-major', 2, 3, 0, A, 3, B, 3 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0, 6.0, 6.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] ); B = new Complex64Array( 6 ); out = ctriu( 'row-major', 3, 2, 0, A, 2, B, 2 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0, 0.0, 0.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -275,13 +276,13 @@ tape( 'the function supports non-square matrices (column-major)', function test( B = new Complex64Array( 6 ); out = ctriu( 'column-major', 2, 3, 0, A, 2, B, 2 ); expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 3.0, 3.0, 6.0, 6.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); A = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 5.0, 5.0, 2.0, 2.0, 4.0, 4.0, 6.0, 6.0 ] ); B = new Complex64Array( 6 ); out = ctriu( 'column-major', 3, 2, 0, A, 3, B, 3 ); expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 4.0, 4.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -296,13 +297,13 @@ tape( 'the function supports a leading dimension greater than the number of rows B = new Complex64Array( 6 ); out = ctriu( 'row-major', 2, 2, 0, A, 3, B, 3 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); A = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 9.0, 9.0, 2.0, 2.0, 4.0, 4.0, 9.0, 9.0 ] ); B = new Complex64Array( 6 ); out = ctriu( 'column-major', 2, 2, 0, A, 3, B, 3 ); expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 4.0, 4.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -319,7 +320,7 @@ tape( 'the function leaves elements outside of the copied region unchanged', fun out = ctriu( 'row-major', 3, 3, 0, A, 3, B, 3 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, -1.0, -1.0, 5.0, 5.0, 6.0, 6.0, -1.0, -1.0, -1.0, -1.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -335,7 +336,7 @@ tape( 'when `k` is greater than or equal to `N`, the function copies nothing', f out = ctriu( 'row-major', 2, 2, 2, A, 2, B, 2 ); expected = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -351,7 +352,7 @@ tape( 'when `k` is sufficiently negative, the function copies the entire matrix' out = ctriu( 'row-major', 2, 2, -2, A, 2, B, 2 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -366,11 +367,11 @@ tape( 'the function leaves `B` unchanged when `M` or `N` is equal to zero', func B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); out = ctriu( 'row-major', 0, 2, 0, A, 2, B, 2 ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); out = ctriu( 'row-major', 2, 0, 0, A, 2, B, 2 ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ctriu.native.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ctriu.native.js index 5c7d11d03711..aad342660f28 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ctriu.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ctriu.native.js @@ -22,6 +22,7 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); var Complex64Array = require( '@stdlib/array/complex64' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -169,7 +170,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 9.0, 9.0 ] ); t.strictEqual( out, B, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -185,7 +186,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k out = ctriu( 'row-major', 3, 3, 1, A, 3, B, 3 ); expected = new Complex64Array( [ 0.0, 0.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 0.0, 0.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -201,7 +202,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k out = ctriu( 'row-major', 3, 3, -1, A, 3, B, 3 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 0.0, 0.0, 8.0, 8.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -217,7 +218,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (column-major out = ctriu( 'column-major', 3, 3, 0, A, 3, B, 3 ); expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 0.0, 0.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -233,7 +234,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (column-major out = ctriu( 'column-major', 3, 3, -1, A, 3, B, 3 ); expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -249,7 +250,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (column-major out = ctriu( 'column-major', 3, 3, 1, A, 3, B, 3 ); expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 6.0, 6.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -263,13 +264,13 @@ tape( 'the function supports non-square matrices (row-major)', opts, function te B = new Complex64Array( 6 ); out = ctriu( 'row-major', 2, 3, 0, A, 3, B, 3 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0, 6.0, 6.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); A = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] ); B = new Complex64Array( 6 ); out = ctriu( 'row-major', 3, 2, 0, A, 2, B, 2 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0, 0.0, 0.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -284,13 +285,13 @@ tape( 'the function supports non-square matrices (column-major)', opts, function B = new Complex64Array( 6 ); out = ctriu( 'column-major', 2, 3, 0, A, 2, B, 2 ); expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 3.0, 3.0, 6.0, 6.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); A = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 5.0, 5.0, 2.0, 2.0, 4.0, 4.0, 6.0, 6.0 ] ); B = new Complex64Array( 6 ); out = ctriu( 'column-major', 3, 2, 0, A, 3, B, 3 ); expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 4.0, 4.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -305,13 +306,13 @@ tape( 'the function supports a leading dimension greater than the number of rows B = new Complex64Array( 6 ); out = ctriu( 'row-major', 2, 2, 0, A, 3, B, 3 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); A = new Complex64Array( [ 1.0, 1.0, 3.0, 3.0, 9.0, 9.0, 2.0, 2.0, 4.0, 4.0, 9.0, 9.0 ] ); B = new Complex64Array( 6 ); out = ctriu( 'column-major', 2, 2, 0, A, 3, B, 3 ); expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 4.0, 4.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -328,7 +329,7 @@ tape( 'the function leaves elements outside of the copied region unchanged', opt out = ctriu( 'row-major', 3, 3, 0, A, 3, B, 3 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, -1.0, -1.0, 5.0, 5.0, 6.0, 6.0, -1.0, -1.0, -1.0, -1.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -344,7 +345,7 @@ tape( 'when `k` is greater than or equal to `N`, the function copies nothing', o out = ctriu( 'row-major', 2, 2, 2, A, 2, B, 2 ); expected = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -360,7 +361,7 @@ tape( 'when `k` is sufficiently negative, the function copies the entire matrix' out = ctriu( 'row-major', 2, 2, -2, A, 2, B, 2 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -375,11 +376,11 @@ tape( 'the function leaves `B` unchanged when `M` or `N` is equal to zero', opts B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); out = ctriu( 'row-major', 0, 2, 0, A, 2, B, 2 ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); out = ctriu( 'row-major', 2, 0, 0, A, 2, B, 2 ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ndarray.js index 4aa9dda8488d..ebf78d17b9a4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/test/test.ndarray.js @@ -21,6 +21,7 @@ // MODULES // var tape = require( 'tape' ); +var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); var Complex64Array = require( '@stdlib/array/complex64' ); var ctriu = require( './../lib/ndarray.js' ); @@ -51,7 +52,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 9.0, 9.0 ] ); t.strictEqual( out, B, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -67,7 +68,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k out = ctriu( 3, 3, 1, A, 3, 1, 0, B, 3, 1, 0 ); expected = new Complex64Array( [ 0.0, 0.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 0.0, 0.0, 6.0, 6.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -83,7 +84,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (row-major, k out = ctriu( 3, 3, -1, A, 3, 1, 0, B, 3, 1, 0 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 0.0, 0.0, 8.0, 8.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -99,7 +100,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (column-major out = ctriu( 3, 3, 0, A, 1, 3, 0, B, 1, 3, 0 ); expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 0.0, 0.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -115,7 +116,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (column-major out = ctriu( 3, 3, -1, A, 1, 3, 0, B, 1, 3, 0 ); expected = new Complex64Array( [ 1.0, 1.0, 4.0, 4.0, 0.0, 0.0, 2.0, 2.0, 5.0, 5.0, 8.0, 8.0, 3.0, 3.0, 6.0, 6.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -131,7 +132,7 @@ tape( 'the function copies the upper triangular part of `A` to `B` (column-major out = ctriu( 3, 3, 1, A, 1, 3, 0, B, 1, 3, 0 ); expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 6.0, 6.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -145,7 +146,7 @@ tape( 'the function supports non-square matrices (row-major)', function test( t B = new Complex64Array( 6 ); out = ctriu( 2, 3, 0, A, 3, 1, 0, B, 3, 1, 0 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0, 6.0, 6.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -159,7 +160,7 @@ tape( 'the function supports non-square matrices (column-major)', function test( B = new Complex64Array( 6 ); out = ctriu( 3, 2, 0, A, 1, 3, 0, B, 1, 3, 0 ); expected = new Complex64Array( [ 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 4.0, 4.0, 0.0, 0.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -175,7 +176,7 @@ tape( 'the function supports an `A` offset', function test( t ) { out = ctriu( 2, 2, 0, A, 2, 1, 1, B, 2, 1, 0 ); expected = new Complex64Array( [ 2.0, 2.0, 3.0, 3.0, 0.0, 0.0, 5.0, 5.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -191,7 +192,7 @@ tape( 'the function supports a `B` offset', function test( t ) { out = ctriu( 2, 2, 0, A, 2, 1, 0, B, 2, 1, 2 ); expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -207,7 +208,7 @@ tape( 'the function supports negative strides', function test( t ) { out = ctriu( 2, 2, 0, A, 2, -1, 1, B, 2, 1, 0 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 0.0, 0.0, 4.0, 4.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -223,7 +224,7 @@ tape( 'the function leaves elements outside of the copied region unchanged', fun out = ctriu( 3, 3, 0, A, 3, 1, 0, B, 3, 1, 0 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, -1.0, -1.0, 5.0, 5.0, 6.0, 6.0, -1.0, -1.0, -1.0, -1.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -239,7 +240,7 @@ tape( 'when `k` is greater than or equal to `N`, the function copies nothing', f out = ctriu( 2, 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); expected = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -255,7 +256,7 @@ tape( 'when `k` is sufficiently negative, the function copies the entire matrix' out = ctriu( 2, 2, -2, A, 2, 1, 0, B, 2, 1, 0 ); expected = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -270,11 +271,11 @@ tape( 'the function leaves `B` unchanged when `M` or `N` is equal to zero', func B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); out = ctriu( 0, 2, 0, A, 2, 1, 0, B, 2, 1, 0 ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); B = new Complex64Array( [ 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0 ] ); out = ctriu( 2, 0, 0, A, 2, 1, 0, B, 2, 1, 0 ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); @@ -291,6 +292,6 @@ tape( 'the function supports complex access patterns (non-unit strides and offse out = ctriu( 2, 2, 0, A, 4, 2, 1, B, 4, 2, 1 ); expected = new Complex64Array( [ 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 4.0 ] ); - t.deepEqual( out, expected, 'returns expected value' ); + t.strictEqual( isSameComplex64Array( out, expected ), true, 'returns expected value' ); t.end(); }); From 604e8200ab2a98bc0c119def9a5eac2b309eb57b Mon Sep 17 00:00:00 2001 From: Kaustubh Patange Date: Tue, 4 Aug 2026 11:34:57 +0530 Subject: [PATCH 5/5] Update lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/repl.txt Signed-off-by: Kaustubh Patange --- lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/repl.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/repl.txt index 7bf788b75ad8..857423d9293a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ctriu/docs/repl.txt @@ -55,8 +55,7 @@ {{alias}}.ndarray( M, N, k, A, sa1, sa2, oa, B, sb1, sb2, ob ) Copies the upper triangular part of a single-precision complex floating- - point matrix `A` to another matrix `B` using alternative indexing - semantics. + point matrix `A` to another matrix `B` 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