From 28708d6ace35cf23c65445a18fd6807ebda4b434 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sun, 7 Jun 2026 00:16:58 +0500 Subject: [PATCH 01/12] feat: add blas/ext/base/zcartesian-product --- 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 --- --- .../ext/base/zcartesian-product/README.md | 360 +++++++++ .../zcartesian-product/benchmark/benchmark.js | 116 +++ .../benchmark/benchmark.native.js | 121 +++ .../benchmark/benchmark.ndarray.js | 116 +++ .../benchmark/benchmark.ndarray.native.js | 121 +++ .../zcartesian-product/benchmark/c/Makefile | 146 ++++ .../benchmark/c/benchmark.length.c | 219 +++++ .../ext/base/zcartesian-product/binding.gyp | 265 ++++++ .../ext/base/zcartesian-product/docs/repl.txt | 141 ++++ .../zcartesian-product/docs/types/index.d.ts | 137 ++++ .../zcartesian-product/docs/types/test.ts | 416 ++++++++++ .../zcartesian-product/examples/c/Makefile | 146 ++++ .../zcartesian-product/examples/c/example.c | 48 ++ .../base/zcartesian-product/examples/index.js | 39 + .../ext/base/zcartesian-product/include.gypi | 53 ++ .../stdlib/blas/ext/base/zcartesian_product.h | 46 ++ .../ext/base/zcartesian-product/lib/index.js | 72 ++ .../ext/base/zcartesian-product/lib/main.js | 35 + .../ext/base/zcartesian-product/lib/native.js | 35 + .../base/zcartesian-product/lib/ndarray.js | 133 +++ .../zcartesian-product/lib/ndarray.native.js | 73 ++ .../lib/zcartesian_product.js | 93 +++ .../lib/zcartesian_product.native.js | 89 ++ .../ext/base/zcartesian-product/manifest.json | 92 +++ .../ext/base/zcartesian-product/package.json | 75 ++ .../ext/base/zcartesian-product/src/Makefile | 70 ++ .../ext/base/zcartesian-product/src/addon.c | 86 ++ .../ext/base/zcartesian-product/src/main.c | 146 ++++ .../ext/base/zcartesian-product/test/test.js | 82 ++ .../zcartesian-product/test/test.ndarray.js | 600 ++++++++++++++ .../test/test.ndarray.native.js | 609 ++++++++++++++ .../test/test.zcartesian_product.js | 756 +++++++++++++++++ .../test/test.zcartesian_product.native.js | 765 ++++++++++++++++++ 33 files changed, 6301 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/include/stdlib/blas/ext/base/zcartesian_product.h create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/main.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.zcartesian_product.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.zcartesian_product.native.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md new file mode 100644 index 000000000000..e3142e71185a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md @@ -0,0 +1,360 @@ + + +# zcartesianProduct + +> Compute the Cartesian product for two double-precision complex strided arrays. + +
+ +## Usage + +```javascript +var zcartesianProduct = require( '@stdlib/blas/ext/base/zcartesian-product' ); +``` + +#### zcartesianProduct( order, M, N, x, strideX, y, strideY, out, LDO ) + +Computes the Cartesian product for two double-precision complex strided arrays. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); +var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +var out = new Complex128Array( 8 ); + +// Compute the Cartesian product: +zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); +// out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **M**: number of indexed elements in `x`. +- **N**: number of indexed elements in `y`. +- **x**: first input [`Complex128Array`][@stdlib/array/complex128]. +- **strideX**: stride length for `x`. +- **y**: second input [`Complex128Array`][@stdlib/array/complex128]. +- **strideY**: stride length for `y`. +- **out**: output [`Complex128Array`][@stdlib/array/complex128]. +- **LDO**: stride length between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of `out`). + +The `M`, `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the Cartesian product of every other element: + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var x = new Complex128Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0 ] ); +var y = new Complex128Array( [ 3.0, 0.0, 0.0, 0.0, 4.0, 0.0 ] ); +var out = new Complex128Array( 8 ); + +// Compute the Cartesian product of every other element: +zcartesianProduct( 'row-major', 2, 2, x, 2, y, 2, out, 2 ); +// out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +// Initial arrays... +var x0 = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); +var y0 = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); + +// Create offset views... +var x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var y1 = new Complex128Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var out = new Complex128Array( 8 ); + +// Compute the Cartesian product: +zcartesianProduct( 'row-major', 2, 2, x1, 1, y1, 1, out, 2 ); +// out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +``` + + + +#### zcartesianProduct.ndarray( M, N, x, strideX, offsetX, y, strideY, offsetY, out, strideOut1, strideOut2, offsetOut ) + + + +Computes the Cartesian product for two double-precision complex strided arrays using alternative indexing semantics. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); +var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +var out = new Complex128Array( 8 ); + +// Compute the Cartesian product: +zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); +// out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +``` + +The function has the following additional parameters: + +- **offsetX**: starting index for `x`. +- **offsetY**: starting index for `y`. +- **strideOut1**: stride length for the first dimension of `out`. +- **strideOut2**: stride length for the second dimension of `out`. +- **offsetOut**: starting index for `out`. + +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, to access only the last two elements: + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); +var y = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); +var out = new Complex128Array( 8 ); + +// Compute the Cartesian product: +zcartesianProduct.ndarray( 2, 2, x, 1, 1, y, 1, 1, out, 2, 1, 0 ); +// out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +``` + +
+ + + +
+ +## Notes + +- If `M <= 0` or `N <= 0`, both functions return `out` unchanged. +- Pairs are stored as rows in the output matrix, where the first column contains the first element of each pair and the second column contains the second element. +- For input arrays `x` of length `M` and `y` of length `N`, the output array must contain at least `M * N * 2` indexed elements. +- For row-major order, the `LDO` parameter must be greater than or equal to `2`. For column-major order, the `LDO` parameter must be greater than or equal to `max(1,M*N)`. + +
+ + + +
+ +## Examples + + + +```javascript +var uniform = require( '@stdlib/random/array/uniform' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var zcartesianProduct = require( '@stdlib/blas/ext/base/zcartesian-product' ); + +var M = 3; +var N = 2; +var xbuf = uniform( M * 2, -10, 10 ); +var x = new Complex128Array( xbuf.buffer ); +console.log( x ); + +var ybuf = uniform( N * 2, -10, 10 ); +var y = new Complex128Array( ybuf.buffer ); +console.log( y ); + +var out = new Complex128Array( M * N * 2 ); + +// Compute the Cartesian product: +zcartesianProduct( 'row-major', M, N, x, 1, y, 1, out, 2 ); +console.log( out ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/ext/base/zcartesian_product.h" +``` + + + +#### stdlib_strided_zcartesian_product( order, M, N, \*X, strideX, \*Y, strideY, \*Out, LDO ) + + + +Computes the Cartesian product for two double-precision complex strided arrays. + +```c +#include "stdlib/complex/float64/ctor.h" + +double x[] = { 1.0, 0.0, 2.0, 0.0 }; +double y[] = { 3.0, 0.0, 4.0, 0.0 }; +double out[ 16 ]; + +stdlib_strided_zcartesian_product( CblasRowMajor, 2, 2, (stdlib_complex128_t *)x, 1, (stdlib_complex128_t *)y, 1, (stdlib_complex128_t *)out, 2 ); +``` + +The function accepts the following arguments: + +- **order**: `[in] CBLAS_LAYOUT` storage layout. +- **M**: `[in] CBLAS_INT` number of indexed elements in `X`. +- **N**: `[in] CBLAS_INT` number of indexed elements in `Y`. +- **X**: `[in] stdlib_complex128_t*` first input array. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **Y**: `[in] stdlib_complex128_t*` second input array. +- **strideY**: `[in] CBLAS_INT` stride length for `Y`. +- **Out**: `[out] stdlib_complex128_t*` output array. +- **LDO**: `[in] CBLAS_INT` stride length between successive contiguous vectors of the matrix `Out` (a.k.a., leading dimension of `Out`). For row-major order, must be greater than or equal to `2`. For column-major order, must be greater than or equal to `max(1,M*N)`. + +```c +void stdlib_strided_zcartesian_product( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const stdlib_complex128_t *X, const CBLAS_INT strideX, const stdlib_complex128_t *Y, const CBLAS_INT strideY, stdlib_complex128_t *Out, const CBLAS_INT LDO ); +``` + + + +#### stdlib_strided_zcartesian_product_ndarray( M, N, \*X, strideX, offsetX, \*Y, strideY, offsetY, \*Out, strideOut1, strideOut2, offsetOut ) + + + +Computes the Cartesian product for two double-precision complex strided arrays using alternative indexing semantics. + +```c +#include "stdlib/complex/float64/ctor.h" + +double x[] = { 1.0, 0.0, 2.0, 0.0 }; +double y[] = { 3.0, 0.0, 4.0, 0.0 }; +double out[ 16 ]; + +stdlib_strided_zcartesian_product_ndarray( 2, 2, (stdlib_complex128_t *)x, 1, 0, (stdlib_complex128_t *)y, 1, 0, (stdlib_complex128_t *)out, 2, 1, 0 ); +``` + +The function accepts the following arguments: + +- **M**: `[in] CBLAS_INT` number of indexed elements in `X`. +- **N**: `[in] CBLAS_INT` number of indexed elements in `Y`. +- **X**: `[in] stdlib_complex128_t*` first input array. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. +- **Y**: `[in] stdlib_complex128_t*` second input array. +- **strideY**: `[in] CBLAS_INT` stride length for `Y`. +- **offsetY**: `[in] CBLAS_INT` starting index for `Y`. +- **Out**: `[out] stdlib_complex128_t*` output array. +- **strideOut1**: `[in] CBLAS_INT` stride length for the first dimension of `Out`. +- **strideOut2**: `[in] CBLAS_INT` stride length for the second dimension of `Out`. +- **offsetOut**: `[in] CBLAS_INT` starting index for `Out`. + +```c +void stdlib_strided_zcartesian_product_ndarray( const CBLAS_INT M, const CBLAS_INT N, const stdlib_complex128_t *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const stdlib_complex128_t *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, stdlib_complex128_t *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/ext/base/zcartesian_product.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Create strided input arrays (interleaved real and imaginary components): + double X[] = { 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0 }; + double Y[] = { 5.0, 0.0, 6.0, 0.0, 7.0, 0.0, 8.0, 0.0 }; + + // Specify the number of indexed elements: + const int M = 4; + const int N = 4; + + // Create an output array (M*N pairs, each pair has 2 elements): + double out[ 64 ]; + + // Specify strides: + const int strideX = 1; + const int strideY = 1; + const int LDO = 2; + + // Compute the Cartesian product: + stdlib_strided_zcartesian_product( CblasRowMajor, M, N, (stdlib_complex128_t *)X, strideX, (stdlib_complex128_t *)Y, strideY, (stdlib_complex128_t *)out, LDO ); + + // Print the result: + for ( int i = 0; i < M*N; i++ ) { + printf( "out[ %i ] = ( %lf, %lf )\n", i, out[ i*2 ], out[ (i*2)+1 ] ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.js new file mode 100644 index 000000000000..549c83020457 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.js @@ -0,0 +1,116 @@ +/** +* @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 uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Float64Array = require( '@stdlib/array/float64' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var zcartesianProduct = require( './../lib/zcartesian_product.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var xbuf; + var ybuf; + var obuf; + var out; + var x; + var y; + + xbuf = uniform( len*2, -10.0, 10.0, options ); + ybuf = uniform( len*2, -10.0, 10.0, options ); + obuf = new Float64Array( len * len * 2 ); + x = new Complex128Array( xbuf.buffer ); + y = new Complex128Array( ybuf.buffer ); + out = new Complex128Array( obuf.buffer ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); + if ( isnan( obuf[ i%(len*len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( obuf[ i%(len*len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 3; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.native.js new file mode 100644 index 000000000000..7fe67ab46c68 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.native.js @@ -0,0 +1,121 @@ +/** +* @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 uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var zcartesianProduct = tryRequire( resolve( __dirname, './../lib/zcartesian_product.native.js' ) ); +var opts = { + 'skip': ( zcartesianProduct instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var xbuf; + var ybuf; + var obuf; + var out; + var x; + var y; + + xbuf = uniform( len*2, -10.0, 10.0, options ); + ybuf = uniform( len*2, -10.0, 10.0, options ); + obuf = new Float64Array( len * len * 2 ); + x = new Complex128Array( xbuf.buffer ); + y = new Complex128Array( ybuf.buffer ); + out = new Complex128Array( obuf.buffer ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); + if ( isnan( obuf[ i%(len*len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( obuf[ i%(len*len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 3; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s::native:len=%d', pkg, len ), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..02ec3aeddd18 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.ndarray.js @@ -0,0 +1,116 @@ +/** +* @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 uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Float64Array = require( '@stdlib/array/float64' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var zcartesianProduct = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var xbuf; + var ybuf; + var obuf; + var out; + var x; + var y; + + xbuf = uniform( len*2, -10.0, 10.0, options ); + ybuf = uniform( len*2, -10.0, 10.0, options ); + obuf = new Float64Array( len * len * 2 ); + x = new Complex128Array( xbuf.buffer ); + y = new Complex128Array( ybuf.buffer ); + out = new Complex128Array( obuf.buffer ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // eslint-disable-line max-len + if ( isnan( obuf[ i%(len*len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( obuf[ i%(len*len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 3; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:ndarray:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..3547f9334319 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,121 @@ +/** +* @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 uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Float64Array = require( '@stdlib/array/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var zcartesianProduct = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( zcartesianProduct instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var xbuf; + var ybuf; + var obuf; + var out; + var x; + var y; + + xbuf = uniform( len*2, -10.0, 10.0, options ); + ybuf = uniform( len*2, -10.0, 10.0, options ); + obuf = new Float64Array( len * len * 2 ); + x = new Complex128Array( xbuf.buffer ); + y = new Complex128Array( ybuf.buffer ); + out = new Complex128Array( obuf.buffer ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // eslint-disable-line max-len + if ( isnan( obuf[ i%(len*len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( obuf[ i%(len*len*2) ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 3; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s::native:ndarray:len=%d', pkg, len ), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/Makefile new file mode 100644 index 000000000000..0756dc7da20a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/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/zcartesian-product/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..dc02563a7d92 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/benchmark.length.c @@ -0,0 +1,219 @@ +/** +* @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/zcartesian_product.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float64/ctor.h" +#include +#include +#include +#include +#include + +#define NAME "zcartesian_product" +#define ITERATIONS 1000000 +#define REPEATS 3 +#define MIN 1 +#define MAX 3 + +/** +* 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 [0,1). +* +* @return random number +*/ +static double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark1( int iterations, int len ) { + stdlib_complex128_t *out; + stdlib_complex128_t *x; + stdlib_complex128_t *y; + double elapsed; + double *obuf; + double *xbuf; + double *ybuf; + double t; + int i; + + xbuf = (double *) malloc( len * 2 * sizeof( double ) ); + ybuf = (double *) malloc( len * 2 * sizeof( double ) ); + obuf = (double *) malloc( len * len * 4 * sizeof( double ) ); + x = (stdlib_complex128_t *) xbuf; + y = (stdlib_complex128_t *) ybuf; + out = (stdlib_complex128_t *) obuf; + for ( i = 0; i < len * 2; i++ ) { + xbuf[ i ] = ( rand_double()*200.0 ) - 100.0; + ybuf[ i ] = ( rand_double()*200.0 ) - 100.0; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + stdlib_strided_zcartesian_product( CblasRowMajor, len, len, x, 1, y, 1, out, 2 ); + if ( obuf[ 0 ] != obuf[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( obuf[ 0 ] != obuf[ 0 ] ) { + printf( "should not return NaN\n" ); + } + free( xbuf ); + free( ybuf ); + free( obuf ); + return elapsed; +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int len ) { + stdlib_complex128_t *out; + stdlib_complex128_t *x; + stdlib_complex128_t *y; + double elapsed; + double *obuf; + double *xbuf; + double *ybuf; + double t; + int i; + + xbuf = (double *) malloc( len * 2 * sizeof( double ) ); + ybuf = (double *) malloc( len * 2 * sizeof( double ) ); + obuf = (double *) malloc( len * len * 4 * sizeof( double ) ); + x = (stdlib_complex128_t *) xbuf; + y = (stdlib_complex128_t *) ybuf; + out = (stdlib_complex128_t *) obuf; + for ( i = 0; i < len * 2; i++ ) { + xbuf[ i ] = ( rand_double()*200.0 ) - 100.0; + ybuf[ i ] = ( rand_double()*200.0 ) - 100.0; + } + t = tic(); + for ( i = 0; i < iterations; i++ ) { + stdlib_strided_zcartesian_product_ndarray( len, len, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); + if ( obuf[ 0 ] != obuf[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( obuf[ 0 ] != obuf[ 0 ] ) { + printf( "should not return NaN\n" ); + } + free( xbuf ); + free( ybuf ); + free( obuf ); + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int len; + 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 = (int) pow( 10, i ); + iter = ITERATIONS / (int) pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:len=%d\n", NAME, len ); + elapsed = benchmark1( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:ndarray:len=%d\n", NAME, len ); + elapsed = benchmark2( iter, len ); + 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/zcartesian-product/binding.gyp b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/binding.gyp new file mode 100644 index 000000000000..60dce9d0b31a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/binding.gyp @@ -0,0 +1,265 @@ +# @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', + + # Fortran compiler (to override -Dfortran_compiler=): + 'fortran_compiler%': 'gfortran', + + # Fortran compiler flags: + 'fflags': [ + # Specify the Fortran standard to which a program is expected to conform: + '-std=f95', + + # Indicate that the layout is free-form source code: + '-ffree-form', + + # Aggressive optimization: + '-O3', + + # Enable commonly used warning options: + '-Wall', + + # Warn if source code contains problematic language features: + '-Wextra', + + # Warn if a procedure is called without an explicit interface: + '-Wimplicit-interface', + + # Do not transform names of entities specified in Fortran source files by appending underscores (i.e., don't mangle names, thus allowing easier usage in C wrappers): + '-fno-underscoring', + + # Warn if source code contains Fortran 95 extensions and C-language constructs: + '-pedantic', + + # Compile but do not link (output is an object file): + '-c', + ], + + # 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 + + # Define custom build actions for particular inputs: + 'rules': [ + { + # Define a rule for processing Fortran files: + 'extension': 'f', + + # Define the pathnames to be used as inputs when performing processing: + 'inputs': [ + # Full path of the current input: + '<(RULE_INPUT_PATH)' + ], + + # Define the outputs produced during processing: + 'outputs': [ + # Store an output object file in a directory for placing intermediate results (only accessible within a single target): + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).<(obj)' + ], + + # Define the rule for compiling Fortran based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + + # Rule to compile Fortran on Windows: + { + 'rule_name': 'compile_fortran_windows', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Windows...', + + 'process_outputs_as_sources': 0, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + }, + + # Rule to compile Fortran on non-Windows: + { + 'rule_name': 'compile_fortran_linux', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Linux...', + + 'process_outputs_as_sources': 1, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '-fPIC', # generate platform-independent code + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + } + ], # end condition (OS=="win") + ], # end conditions + }, # end rule (extension=="f") + ], # end rules + }, # 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/zcartesian-product/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/repl.txt new file mode 100644 index 000000000000..e4eee18285e5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/repl.txt @@ -0,0 +1,141 @@ + +{{alias}}( order, M, N, x, strideX, y, strideY, out, LDO ) + Computes the Cartesian product for two double-precision complex strided + arrays. + + The `M`, `N`, and stride parameters determine which elements in the strided + arrays are accessed at runtime. + + Pairs are stored as rows in the output matrix, where the first column + contains the first element of each pair and the second column contains + the second element. + + If `M <= 0` or `N <= 0`, the function returns `out` unchanged. + + Parameters + ---------- + order: string + Storage layout. + + M: integer + Number of indexed elements in `x`. + + N: integer + Number of indexed elements in `y`. + + x: Complex128Array + First input array. + + strideX: integer + Stride length for `x`. + + y: Complex128Array + Second input array. + + strideY: integer + Stride length for `y`. + + out: Complex128Array + Output array. + + LDO: integer + Stride length between successive contiguous vectors of the matrix + `out` (a.k.a., leading dimension of `out`). For row-major order, + must be greater than or equal to `2`. For column-major order, must + be greater than or equal to `max(1,M*N)`. + + Returns + ------- + out: Complex128Array + Output array. + + Examples + -------- + // Standard Usage: + > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 0.0 ] ); + > var y = new {{alias:@stdlib/array/complex128}}( [ 3.0, 0.0, 4.0, 0.0 ] ); + > var out = new {{alias:@stdlib/array/complex128}}( 4 ); + > {{alias}}( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ) + [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0 ] + + // Using `M`, `N`, and stride parameters: + > x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 0.0, 2.0, 0.0 ] ); + > y = new {{alias:@stdlib/array/complex128}}( [ 3.0, 0.0, 4.0, 0.0 ] ); + > out = new {{alias:@stdlib/array/complex128}}( 4 ); + > {{alias}}( 'row-major', 1, 2, x, 2, y, 1, out, 2 ) + [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0 ] + + +{{alias}}.ndarray( M, N, x, sx, ox, y, sy, oy, out, so1, so2, oo ) + Computes the Cartesian product for two double-precision complex strided + arrays using alternative indexing semantics. + + Pairs are stored as rows in the output matrix, where the first column + contains the first element of each pair and the second column contains + the second element. + + 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 indexed elements in `x`. + + N: integer + Number of indexed elements in `y`. + + x: Complex128Array + First input array. + + sx: integer + Stride length for `x`. + + ox: integer + Starting index for `x`. + + y: Complex128Array + Second input array. + + sy: integer + Stride length for `y`. + + oy: integer + Starting index for `y`. + + out: Complex128Array + Output array. + + so1: integer + Stride length for the first dimension of `out`. + + so2: integer + Stride length for the second dimension of `out`. + + oo: integer + Starting index for `out`. + + Returns + ------- + out: Complex128Array + Output array. + + Examples + -------- + // Standard Usage: + > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 0.0 ] ); + > var y = new {{alias:@stdlib/array/complex128}}( [ 3.0, 0.0, 4.0, 0.0 ] ); + > var out = new {{alias:@stdlib/array/complex128}}( 4 ); + > {{alias}}.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ) + [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0 ] + + // Using an index offset: + > x = new {{alias:@stdlib/array/complex128}}( [ 0.0, 0.0, 1.0, 0.0 ] ); + > y = new {{alias:@stdlib/array/complex128}}( [ 3.0, 0.0, 4.0, 0.0 ] ); + > out = new {{alias:@stdlib/array/complex128}}( 4 ); + > {{alias}}.ndarray( 1, 2, x, 1, 1, y, 1, 0, out, 2, 1, 0 ) + [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/types/index.d.ts new file mode 100644 index 000000000000..e851dc068b96 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/types/index.d.ts @@ -0,0 +1,137 @@ +/* +* @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 { Complex128Array } from '@stdlib/types/array'; + +/** +* Interface describing `zcartesianProduct`. +*/ +interface Routine { + /** + * Computes the Cartesian product for two double-precision complex strided arrays. + * + * ## Notes + * + * - Pairs are stored as rows in the output matrix, where the first column contains the first element of each pair and the second column contains the second element. + * + * @param order - storage layout + * @param M - number of indexed elements in `x` + * @param N - number of indexed elements in `y` + * @param x - first input array + * @param strideX - stride length for `x` + * @param y - second input array + * @param strideY - stride length for `y` + * @param out - output array + * @param LDO - stride length between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of `out`) + * @returns output array + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * + * var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + * var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + * var out = new Complex128Array( 8 ); + * + * zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); + * // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] + */ + ( order: Layout, M: number, N: number, x: Complex128Array, strideX: number, y: Complex128Array, strideY: number, out: Complex128Array, LDO: number ): Complex128Array; + + /** + * Computes the Cartesian product for two double-precision complex strided arrays using alternative indexing semantics. + * + * ## Notes + * + * - Pairs are stored as rows in the output matrix, where the first column contains the first element of each pair and the second column contains the second element. + * + * @param M - number of indexed elements in `x` + * @param N - number of indexed elements in `y` + * @param x - first input array + * @param strideX - stride length for `x` + * @param offsetX - starting index for `x` + * @param y - second input array + * @param strideY - stride length for `y` + * @param offsetY - starting index for `y` + * @param out - output array + * @param strideOut1 - stride length for the first dimension of `out` + * @param strideOut2 - stride length for the second dimension of `out` + * @param offsetOut - starting index for `out` + * @returns output array + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * + * var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + * var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + * var out = new Complex128Array( 8 ); + * + * zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); + * // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] + */ + ndarray( M: number, N: number, x: Complex128Array, strideX: number, offsetX: number, y: Complex128Array, strideY: number, offsetY: number, out: Complex128Array, strideOut1: number, strideOut2: number, offsetOut: number ): Complex128Array; +} + +/** +* Computes the Cartesian product for two double-precision complex strided arrays. +* +* ## Notes +* +* - Pairs are stored as rows in the output matrix, where the first column contains the first element of each pair and the second column contains the second element. +* +* @param order - storage layout +* @param M - number of indexed elements in `x` +* @param N - number of indexed elements in `y` +* @param x - first input array +* @param strideX - stride length for `x` +* @param y - second input array +* @param strideY - stride length for `y` +* @param out - output array +* @param LDO - stride length between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of `out`) +* @returns output array +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); +* var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +* var out = new Complex128Array( 8 ); +* +* zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); +* // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); +* var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +* var out = new Complex128Array( 8 ); +* +* zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); +* // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +*/ +declare var zcartesianProduct: Routine; + + +// EXPORTS // + +export = zcartesianProduct; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/types/test.ts new file mode 100644 index 000000000000..56b0f7ab55df --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/types/test.ts @@ -0,0 +1,416 @@ +/* +* @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 Complex128Array = require( '@stdlib/array/complex128' ); +import zcartesianProduct = require( './index' ); + + +// TESTS // + +// The function returns a Complex128Array... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); // $ExpectType Complex128Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct( 10, x.length, y.length, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( true, x.length, y.length, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( false, x.length, y.length, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( null, x.length, y.length, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( undefined, x.length, y.length, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( [], x.length, y.length, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( {}, x.length, y.length, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( ( x: number ): number => x, x.length, y.length, x, 1, y, 1, out, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct( 'row-major', '10', y.length, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', true, y.length, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', false, y.length, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', null, y.length, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', undefined, y.length, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', [], y.length, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', {}, y.length, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', ( x: number ): number => x, y.length, x, 1, y, 1, out, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct( 'row-major', x.length, '10', x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, true, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, false, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, null, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, undefined, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, [], x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, {}, x, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, ( x: number ): number => x, x, 1, y, 1, out, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Complex128Array... +{ + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct( 'row-major', 2, y.length, 10, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', 2, y.length, '10', 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', 2, y.length, true, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', 2, y.length, false, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', 2, y.length, null, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', 2, y.length, undefined, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', 2, y.length, [], 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', 2, y.length, {}, 1, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', 2, y.length, ( x: number ): number => x, 1, y, 1, out, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct( 'row-major', x.length, y.length, x, '10', y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, true, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, false, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, null, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, undefined, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, [], y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, {}, y, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, ( x: number ): number => x, y, 1, out, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Complex128Array... +{ + const x = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct( 'row-major', x.length, 2, x, 1, 10, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, 2, x, 1, '10', 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, 2, x, 1, true, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, 2, x, 1, false, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, 2, x, 1, null, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, 2, x, 1, undefined, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, 2, x, 1, [], 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, 2, x, 1, {}, 1, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, 2, x, 1, ( x: number ): number => x, 1, out, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, '10', out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, true, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, false, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, null, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, undefined, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, [], out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, {}, out, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, ( x: number ): number => x, out, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a Complex128Array... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, 10, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, '10', 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, true, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, false, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, null, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, undefined, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, [], 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, {}, 2 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, ( x: number ): number => x, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, '10' ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, true ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, false ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, null ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, undefined ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, [] ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, {} ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct(); // $ExpectError + zcartesianProduct( 'row-major' ); // $ExpectError + zcartesianProduct( 'row-major', x.length ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2, 1 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Complex128Array... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectType Complex128Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct.ndarray( '10', y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( true, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( false, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( null, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( undefined, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( [], y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( {}, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( ( x: number ): number => x, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct.ndarray( x.length, '10', x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, true, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, false, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, null, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, undefined, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, [], x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, {}, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, ( x: number ): number => x, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a Complex128Array... +{ + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct.ndarray( 2, y.length, 10, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( 2, y.length, '10', 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( 2, y.length, true, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( 2, y.length, false, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( 2, y.length, null, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( 2, y.length, undefined, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( 2, y.length, [], 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( 2, y.length, {}, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( 2, y.length, ( x: number ): number => x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct.ndarray( x.length, y.length, x, '10', 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, true, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, false, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, null, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, undefined, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, [], 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, {}, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, ( x: number ): number => x, 0, y, 1, 0, out, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct.ndarray( x.length, y.length, x, 1, '10', y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, true, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, false, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, null, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, undefined, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, [], y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, {}, y, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, ( x: number ): number => x, y, 1, 0, out, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a Complex128Array... +{ + const x = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct.ndarray( x.length, 2, x, 1, 0, 10, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, 2, x, 1, 0, '10', 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, 2, x, 1, 0, true, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, 2, x, 1, 0, false, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, 2, x, 1, 0, null, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, 2, x, 1, 0, undefined, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, 2, x, 1, 0, [], 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, 2, x, 1, 0, {}, 1, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, 2, x, 1, 0, ( x: number ): number => x, 1, 0, out, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, '10', 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, true, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, false, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, null, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, undefined, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, [], 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, {}, 0, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, ( x: number ): number => x, 0, out, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, '10', out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, true, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, false, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, null, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, undefined, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, [], out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, {}, out, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, ( x: number ): number => x, out, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a Complex128Array... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, 10, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, '10', 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, true, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, false, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, null, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, undefined, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, [], 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, {}, 2, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, ( x: number ): number => x, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a tenth argument which is not a number... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, '10', 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, true, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, false, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, null, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, undefined, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, [], 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, {}, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eleventh argument which is not a number... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, '10', 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, true, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, false, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, null, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, undefined, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, [], 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, {}, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a twelfth argument which is not a number... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, '10' ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, true ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, false ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, null ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, undefined ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, [] ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, {} ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Complex128Array( 2 ); + const y = new Complex128Array( 2 ); + const out = new Complex128Array( 8 ); + + zcartesianProduct.ndarray(); // $ExpectError + zcartesianProduct.ndarray( x.length ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1 ); // $ExpectError + zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/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/zcartesian-product/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/c/example.c new file mode 100644 index 000000000000..0062ec39eff1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/c/example.c @@ -0,0 +1,48 @@ +/** +* @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/zcartesian_product.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/blas/base/shared.h" +#include + +int main( void ) { + // Create strided input arrays (interleaved real and imaginary components): + double X[] = { 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0 }; + double Y[] = { 5.0, 0.0, 6.0, 0.0, 7.0, 0.0, 8.0, 0.0 }; + + // Specify the number of indexed elements: + const int M = 4; + const int N = 4; + + // Create an output array (M*N pairs, each pair has 2 elements): + double out[ 64 ]; + + // Specify strides: + const int strideX = 1; + const int strideY = 1; + const int LDO = 2; + + // Compute the Cartesian product: + stdlib_strided_zcartesian_product( CblasRowMajor, M, N, (stdlib_complex128_t *)X, strideX, (stdlib_complex128_t *)Y, strideY, (stdlib_complex128_t *)out, LDO ); + + // Print the result: + for ( int i = 0; i < M*N; i++ ) { + printf( "out[ %i ] = ( %lf, %lf )\n", i, out[ i*2 ], out[ (i*2)+1 ] ); + } +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/index.js new file mode 100644 index 000000000000..91319aedf4c9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/index.js @@ -0,0 +1,39 @@ +/** +* @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 uniform = require( '@stdlib/random/array/uniform' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var zcartesianProduct = require( './../lib' ); + +var M = 3; +var N = 2; +var xbuf = uniform( M * 2, -10, 10 ); +var x = new Complex128Array( xbuf.buffer ); +console.log( x ); + +var ybuf = uniform( N * 2, -10, 10 ); +var y = new Complex128Array( ybuf.buffer ); +console.log( y ); + +var out = new Complex128Array( M * N * 2 ); + +// Compute the Cartesian product: +zcartesianProduct( 'row-major', M, N, x, 1, y, 1, out, 2 ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/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, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var zcartesianProduct = require( '@stdlib/blas/ext/base/zcartesian-product' ); +* +* var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); +* var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +* var out = new Complex128Array( 8 ); +* +* zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); +* // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.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 zcartesianProduct; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + zcartesianProduct = main; +} else { + zcartesianProduct = tmp; +} + + +// EXPORTS // + +module.exports = zcartesianProduct; + +// exports: { "ndarray": "zcartesianProduct.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/main.js new file mode 100644 index 000000000000..8de916d42775 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/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 zcartesianProduct = require( './zcartesian_product.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( zcartesianProduct, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = zcartesianProduct; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/native.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/native.js new file mode 100644 index 000000000000..fdfd61d58e0a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/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 zcartesianProduct = require( './zcartesian_product.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( zcartesianProduct, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = zcartesianProduct; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js new file mode 100644 index 000000000000..98f953ddbf60 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js @@ -0,0 +1,133 @@ +/** +* @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. +*/ + +/* eslint-disable max-params */ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var zfill = require( '@stdlib/blas/ext/base/zfill' ).ndarray; +var zcopy = require( '@stdlib/blas/base/zcopy' ).ndarray; +var Complex128 = require( '@stdlib/complex/float64/ctor' ); + + +// MAIN // + +/** +* Computes the Cartesian product for two double-precision complex strided arrays using alternative indexing semantics. +* +* ## Notes +* +* - Pairs are stored as rows in the output matrix, where the first column contains the first element of each pair and the second column contains the second element. +* +* @param {NonNegativeInteger} M - number of indexed elements in `x` +* @param {NonNegativeInteger} N - number of indexed elements in `y` +* @param {Complex128Array} x - first input array +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Complex128Array} y - second input array +* @param {integer} strideY - stride length for `y` +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @param {Complex128Array} out - output array +* @param {integer} strideOut1 - stride length for the first dimension of `out` +* @param {integer} strideOut2 - stride length for the second dimension of `out` +* @param {NonNegativeInteger} offsetOut - starting index for `out` +* @returns {Complex128Array} output array +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); +* var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +* var out = new Complex128Array( 8 ); +* +* zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); +* // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +*/ +function zcartesianProduct( M, N, x, strideX, offsetX, y, strideY, offsetY, out, strideOut1, strideOut2, offsetOut ) { // eslint-disable-line max-len + var xView; + var yView; + var oView; + var sx; + var sy; + var s1; + var s2; + var ox; + var oy; + var oo; + var iy; + var ix; + var io; + var i; + var j; + + if ( M <= 0 || N <= 0 ) { + return out; + } + // Reinterpret complex arrays as real-valued arrays: + xView = reinterpret( x, 0 ); + yView = reinterpret( y, 0 ); + oView = reinterpret( out, 0 ); + + // Adjusted strides and offsets for reinterpreted arrays: + sx = strideX * 2; + sy = strideY * 2; + s1 = strideOut1 * 2; + s2 = strideOut2 * 2; + ox = offsetX * 2; + oy = offsetY * 2; + oo = offsetOut * 2; + + ix = ox; + io = oo; + if ( isRowMajor( [ strideOut1, strideOut2 ] ) ) { + for ( i = 0; i < M; i++ ) { + iy = oy; + for ( j = 0; j < N; j++ ) { + oView[ io ] = xView[ ix ]; + oView[ io + 1 ] = xView[ ix + 1 ]; + oView[ io + s2 ] = yView[ iy ]; + oView[ io + s2 + 1 ] = yView[ iy + 1 ]; + iy += sy; + io += s1; + } + ix += sx; + } + return out; + } + // Column-major... + io = offsetOut; + for ( i = 0; i < M; i++ ) { + zfill( N, new Complex128( xView[ ox + (i*sx) ], xView[ ox + (i*sx) + 1 ] ), out, strideOut1, io ); // eslint-disable-line max-len + io += N * strideOut1; + } + io = offsetOut + strideOut2; + for ( i = 0; i < M; i++ ) { + zcopy( N, y, strideY, offsetY, out, strideOut1, io ); + io += N * strideOut1; + } + return out; +} + + +// EXPORTS // + +module.exports = zcartesianProduct; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.native.js new file mode 100644 index 000000000000..992edb217f2f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.native.js @@ -0,0 +1,73 @@ +/** +* @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. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Computes the Cartesian product for two double-precision complex strided arrays using alternative indexing semantics. +* +* ## Notes +* +* - Pairs are stored as rows in the output matrix, where the first column contains the first element of each pair and the second column contains the second element. +* +* @param {NonNegativeInteger} M - number of indexed elements in `x` +* @param {NonNegativeInteger} N - number of indexed elements in `y` +* @param {Complex128Array} x - first input array +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Complex128Array} y - second input array +* @param {integer} strideY - stride length for `y` +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @param {Complex128Array} out - output array +* @param {integer} strideOut1 - stride length for the first dimension of `out` +* @param {integer} strideOut2 - stride length for the second dimension of `out` +* @param {NonNegativeInteger} offsetOut - starting index for `out` +* @returns {Complex128Array} output array +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); +* var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +* var out = new Complex128Array( 8 ); +* +* zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); +* // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +*/ +function zcartesianProduct( M, N, x, strideX, offsetX, y, strideY, offsetY, out, strideOut1, strideOut2, offsetOut ) { + var xView = reinterpret( x, 0 ); + var yView = reinterpret( y, 0 ); + var oView = reinterpret( out, 0 ); + addon.ndarray( M, N, xView, strideX, offsetX, yView, strideY, offsetY, oView, strideOut1, strideOut2, offsetOut ); + return out; +} + + +// EXPORTS // + +module.exports = zcartesianProduct; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.js new file mode 100644 index 000000000000..8c9c26bc7b6a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.js @@ -0,0 +1,93 @@ +/** +* @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 isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var format = require( '@stdlib/string/format' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Computes the Cartesian product for two double-precision complex strided arrays. +* +* ## Notes +* +* - Pairs are stored as rows in the output matrix, where the first column contains the first element of each pair and the second column contains the second element. +* +* @param {string} order - storage layout +* @param {NonNegativeInteger} M - number of indexed elements in `x` +* @param {NonNegativeInteger} N - number of indexed elements in `y` +* @param {Complex128Array} x - first input array +* @param {integer} strideX - stride length for `x` +* @param {Complex128Array} y - second input array +* @param {integer} strideY - stride length for `y` +* @param {Complex128Array} out - output array +* @param {integer} LDO - stride length between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of `out`) +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} ninth argument must be a valid stride length +* @returns {Complex128Array} output array +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); +* var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +* var out = new Complex128Array( 8 ); +* +* zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); +* // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +*/ +function zcartesianProduct( order, M, N, x, strideX, y, strideY, out, LDO ) { + var sa1; + var sa2; + var ox; + var oy; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( isColumnMajor( order ) ) { + if ( LDO < max( 1, M*N ) ) { + throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to max(1,%d). Value: `%d`.', M*N, LDO ) ); + } + sa1 = 1; + sa2 = LDO; + } else { // order === 'row-major' + if ( LDO < 2 ) { + throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to max(1,%d). Value: `%d`.', 2, LDO ) ); + } + sa1 = LDO; + sa2 = 1; + } + ox = stride2offset( M, strideX ); + oy = stride2offset( N, strideY ); + return ndarray( M, N, x, strideX, ox, y, strideY, oy, out, sa1, sa2, 0 ); +} + + +// EXPORTS // + +module.exports = zcartesianProduct; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.native.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.native.js new file mode 100644 index 000000000000..1d44cf7cf488 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.native.js @@ -0,0 +1,89 @@ +/** +* @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 isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-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-complex128' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Computes the Cartesian product for two double-precision complex strided arrays. +* +* ## Notes +* +* - Pairs are stored as rows in the output matrix, where the first column contains the first element of each pair and the second column contains the second element. +* +* @param {string} order - storage layout +* @param {NonNegativeInteger} M - number of indexed elements in `x` +* @param {NonNegativeInteger} N - number of indexed elements in `y` +* @param {Complex128Array} x - first input array +* @param {integer} strideX - stride length for `x` +* @param {Complex128Array} y - second input array +* @param {integer} strideY - stride length for `y` +* @param {Complex128Array} out - output array +* @param {integer} LDO - stride length between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of `out`) +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} ninth argument must be a valid stride length +* @returns {Complex128Array} output array +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); +* var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +* var out = new Complex128Array( 8 ); +* +* zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); +* // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +*/ +function zcartesianProduct( order, M, N, x, strideX, y, strideY, out, LDO ) { + var xView; + var yView; + var oView; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( isColumnMajor( order ) ) { + if ( LDO < max( 1, M*N ) ) { + throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to max(1,%d). Value: `%d`.', M*N, LDO ) ); + } + } else if ( LDO < 2 ) { // order === 'row-major' + throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to max(1,%d). Value: `%d`.', 2, LDO ) ); + } + xView = reinterpret( x, 0 ); + yView = reinterpret( y, 0 ); + oView = reinterpret( out, 0 ); + addon( resolveOrder( order ), M, N, xView, strideX, yView, strideY, oView, LDO ); + return out; +} + + +// EXPORTS // + +module.exports = zcartesianProduct; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/manifest.json new file mode 100644 index 000000000000..022b993df0b4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/manifest.json @@ -0,0 +1,92 @@ +{ + "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/zcopy", + "@stdlib/blas/base/shared", + "@stdlib/blas/ext/base/zfill", + "@stdlib/complex/float64/ctor", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int32", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/napi/argv-strided-complex128array2d" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/zcopy", + "@stdlib/blas/base/shared", + "@stdlib/blas/ext/base/zfill", + "@stdlib/complex/float64/ctor", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/zcopy", + "@stdlib/blas/base/shared", + "@stdlib/blas/ext/base/zfill", + "@stdlib/complex/float64/ctor", + "@stdlib/ndarray/base/assert/is-row-major", + "@stdlib/strided/base/stride2offset" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/package.json b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/package.json new file mode 100644 index 000000000000..b530f944f217 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/package.json @@ -0,0 +1,75 @@ +{ + "name": "@stdlib/blas/ext/base/zcartesian-product", + "version": "0.0.0", + "description": "Compute the Cartesian product for two double-precision complex strided arrays.", + "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", + "stdmath", + "mathematics", + "math", + "blas", + "extended", + "cartesian", + "product", + "strided", + "array", + "ndarray", + "complex128", + "complex", + "double-precision", + "complex128array" + ], + "__stdlib__": { + "wasm": false + } +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/Makefile b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/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/zcartesian-product/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/addon.c new file mode 100644 index 000000000000..0a006eb0a393 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/addon.c @@ -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. +*/ + +#include "stdlib/blas/ext/base/zcartesian_product.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int32.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_complex128array.h" +#include "stdlib/napi/argv_strided_complex128array2d.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 ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 9 ); + STDLIB_NAPI_ARGV_INT32( env, order, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, M, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 4 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 6 ); + STDLIB_NAPI_ARGV_INT64( env, LDO, argv, 8 ); + + CBLAS_INT sa1; + CBLAS_INT sa2; + if ( order == CblasColMajor ) { + sa1 = 1; + sa2 = LDO; + } else { // order == CblasRowMajor + sa1 = LDO; + sa2 = 1; + } + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, X, M, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, Y, N, strideY, argv, 5 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY2D( env, Out, M*N, 2, sa1, sa2, argv, 7 ); + API_SUFFIX(stdlib_strided_zcartesian_product)( order, M, N, (stdlib_complex128_t *)X, strideX, (stdlib_complex128_t *)Y, strideY, (stdlib_complex128_t *)Out, LDO ); + 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, 12 ); + STDLIB_NAPI_ARGV_INT64( env, M, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 4 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 6 ); + STDLIB_NAPI_ARGV_INT64( env, offsetY, argv, 7 ); + STDLIB_NAPI_ARGV_INT64( env, strideOut1, argv, 9 ); + STDLIB_NAPI_ARGV_INT64( env, strideOut2, argv, 10 ); + STDLIB_NAPI_ARGV_INT64( env, offsetOut, argv, 11 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, X, M, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, Y, N, strideY, argv, 5 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY2D( env, Out, M*N, 2, strideOut1, strideOut2, argv, 8 ); + API_SUFFIX(stdlib_strided_zcartesian_product_ndarray)( M, N, (stdlib_complex128_t *)X, strideX, offsetX, (stdlib_complex128_t *)Y, strideY, offsetY, (stdlib_complex128_t *)Out, strideOut1, strideOut2, offsetOut ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/main.c new file mode 100644 index 000000000000..e3551962dc7f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/main.c @@ -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. +*/ + +#include "stdlib/blas/ext/base/zcartesian_product.h" +#include "stdlib/blas/ext/base/zfill.h" +#include "stdlib/blas/base/zcopy.h" +#include "stdlib/ndarray/base/assert/is_row_major.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" +#include "stdlib/complex/float64/ctor.h" + +/** +* Computes the Cartesian product for two double-precision complex strided arrays. +* +* ## Notes +* +* - Pairs are stored as rows in the output matrix, where the first column contains the first element of each pair and the second column contains the second element. +* +* @param order storage layout +* @param M number of indexed elements in X +* @param N number of indexed elements in Y +* @param X first input array +* @param strideX stride length for X +* @param Y second input array +* @param strideY stride length for Y +* @param Out output array +* @param LDO stride length between successive contiguous vectors of the matrix Out (a.k.a., leading dimension of Out) +*/ +void API_SUFFIX(stdlib_strided_zcartesian_product)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const stdlib_complex128_t *X, const CBLAS_INT strideX, const stdlib_complex128_t *Y, const CBLAS_INT strideY, stdlib_complex128_t *Out, const CBLAS_INT LDO ) { + CBLAS_INT sa1; + CBLAS_INT sa2; + CBLAS_INT ox; + CBLAS_INT oy; + + if ( order == CblasColMajor ) { + sa1 = 1; + sa2 = LDO; + } else { // order == CblasRowMajor + sa1 = LDO; + sa2 = 1; + } + ox = stdlib_strided_stride2offset( M, strideX ); + oy = stdlib_strided_stride2offset( N, strideY ); + API_SUFFIX(stdlib_strided_zcartesian_product_ndarray)( M, N, X, strideX, ox, Y, strideY, oy, Out, sa1, sa2, 0 ); +} + +/** +* Computes the Cartesian product for two double-precision complex strided arrays using alternative indexing semantics. +* +* ## Notes +* +* - Pairs are stored as rows in the output matrix, where the first column contains the first element of each pair and the second column contains the second element. +* +* @param M number of indexed elements in X +* @param N number of indexed elements in Y +* @param X first input array +* @param strideX stride length for X +* @param offsetX starting index for X +* @param Y second input array +* @param strideY stride length for Y +* @param offsetY starting index for Y +* @param Out output array +* @param strideOut1 stride length for the first dimension of Out +* @param strideOut2 stride length for the second dimension of Out +* @param offsetOut starting index for Out +*/ +void API_SUFFIX(stdlib_strided_zcartesian_product_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const stdlib_complex128_t *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const stdlib_complex128_t *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, stdlib_complex128_t *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ) { + const double *xView = (double *)X; + const double *yView = (double *)Y; + double *oView = (double *)Out; + int64_t sa[ 2 ]; + CBLAS_INT isrm; + CBLAS_INT sx; + CBLAS_INT sy; + CBLAS_INT s1; + CBLAS_INT s2; + CBLAS_INT iy; + CBLAS_INT ix; + CBLAS_INT io; + CBLAS_INT ox; + CBLAS_INT oy; + CBLAS_INT oo; + CBLAS_INT i; + CBLAS_INT j; + + if ( M <= 0 || N <= 0 ) { + return; + } + + // Adjusted strides and offsets for reinterpreted arrays: + sx = strideX * 2; + sy = strideY * 2; + s1 = strideOut1 * 2; + s2 = strideOut2 * 2; + ox = offsetX * 2; + oy = offsetY * 2; + oo = offsetOut * 2; + + sa[ 0 ] = strideOut1; + sa[ 1 ] = strideOut2; + isrm = stdlib_ndarray_is_row_major( 2, sa ); + ix = ox; + io = oo; + if ( isrm ) { + for ( i = 0; i < M; i++ ) { + iy = oy; + for ( j = 0; j < N; j++ ) { + oView[ io ] = xView[ ix ]; + oView[ io + 1 ] = xView[ ix + 1 ]; + oView[ io + s2 ] = yView[ iy ]; + oView[ io + s2 + 1 ] = yView[ iy + 1 ]; + iy += sy; + io += s1; + } + ix += sx; + } + return; + } + // Column-major... + io = offsetOut; + for ( i = 0; i < M; i++ ) { + API_SUFFIX(stdlib_strided_zfill_ndarray)( N, stdlib_complex128( xView[ ox + (i*sx) ], xView[ ox + (i*sx) + 1 ] ), Out, strideOut1, io ); + io += N * strideOut1; + } + io = offsetOut + strideOut2; + for ( i = 0; i < M; i++ ) { + API_SUFFIX(c_zcopy_ndarray)( N, Y, strideY, offsetY, Out, strideOut1, io ); + io += N * strideOut1; + } + return; +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.js new file mode 100644 index 000000000000..80a15452a64e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/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 zcartesianProduct = 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 zcartesianProduct, '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 zcartesianProduct.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 zcartesianProduct = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( zcartesianProduct, 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 zcartesianProduct; + var main; + + main = require( './../lib/zcartesian_product.js' ); + + zcartesianProduct = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( zcartesianProduct, main, 'returns JavaScript implementation' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.ndarray.js new file mode 100644 index 000000000000..1db38b5ba45a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.ndarray.js @@ -0,0 +1,600 @@ +/** +* @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 isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var zcartesianProduct = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zcartesianProduct, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 12', function test( t ) { + t.strictEqual( zcartesianProduct.length, 12, 'has expected arity' ); + t.end(); +}); + +tape( 'the function computes the Cartesian product', function test( t ) { + var expected; + var out; + var x; + var y; + + // Row-major: + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); + y = new Complex128Array( [ 10.0, 0.0, 20.0, 0.0 ] ); + out = new Complex128Array( 12 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 10.0, + 0.0, + 1.0, + 0.0, + 20.0, + 0.0, + 2.0, + 0.0, + 10.0, + 0.0, + 2.0, + 0.0, + 20.0, + 0.0, + 3.0, + 0.0, + 10.0, + 0.0, + 3.0, + 0.0, + 20.0, + 0.0 + ]); + + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the output array', function test( t ) { + var out; + var x; + var y; + var z; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + z = zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); + + t.strictEqual( z, out, 'same reference' ); + t.end(); +}); + +tape( 'if provided an `M` or `N` parameter equal to `0`, the function returns the output array unchanged', function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array([ + 5.0, + 0.0, + 6.0, + 0.0, + 7.0, + 0.0, + 8.0, + 0.0 + ]); + expected = new Complex128Array([ + 5.0, + 0.0, + 6.0, + 0.0, + 7.0, + 0.0, + 8.0, + 0.0 + ]); + + zcartesianProduct( 0, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + zcartesianProduct( x.length, 0, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride for `x`', function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array([ + 1.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0 + ]); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 2, y.length, x, 2, 0, y, 1, 0, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `x`', function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array([ + 2.0, + 0.0, + 1.0, + 0.0 + ]); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 2, y.length, x, -1, 1, y, 1, 0, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride for `y`', function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array([ + 3.0, + 0.0, + 0.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0 + ]); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( x.length, 2, x, 1, 0, y, 2, 0, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `y`', function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array([ + 4.0, + 0.0, + 3.0, + 0.0 + ]); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( x.length, 2, x, 1, 0, y, -1, 1, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride for the output pairs', function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 16 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 4, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride for the output pairs', function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 2.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 1.0, + 0.0, + 3.0, + 0.0 + ]); + + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, -2, 1, 6 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride for the output pair elements', function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 1.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0 + ]); + + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, -1, 1 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `offsetX` parameter', function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 2, y.length, x, 1, 1, y, 1, 0, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `offsetY` parameter', function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( x.length, 2, x, 1, 0, y, 1, 1, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a column-major output layout', function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 1, 2, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `offsetOut` parameter', function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array([ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + expected = new Complex128Array([ + 0.0, + 0.0, + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 1 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.ndarray.native.js new file mode 100644 index 000000000000..17497168caff --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.ndarray.native.js @@ -0,0 +1,609 @@ +/** +* @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 isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var zcartesianProduct = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( zcartesianProduct instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zcartesianProduct, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 12', opts, function test( t ) { + t.strictEqual( zcartesianProduct.length, 12, 'has expected arity' ); + t.end(); +}); + +tape( 'the function computes the Cartesian product', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + // Row-major: + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); + y = new Complex128Array( [ 10.0, 0.0, 20.0, 0.0 ] ); + out = new Complex128Array( 12 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 10.0, + 0.0, + 1.0, + 0.0, + 20.0, + 0.0, + 2.0, + 0.0, + 10.0, + 0.0, + 2.0, + 0.0, + 20.0, + 0.0, + 3.0, + 0.0, + 10.0, + 0.0, + 3.0, + 0.0, + 20.0, + 0.0 + ]); + + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the output array', opts, function test( t ) { + var out; + var x; + var y; + var z; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + z = zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); + + t.strictEqual( z, out, 'same reference' ); + t.end(); +}); + +tape( 'if provided an `M` or `N` parameter equal to `0`, the function returns the output array unchanged', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array([ + 5.0, + 0.0, + 6.0, + 0.0, + 7.0, + 0.0, + 8.0, + 0.0 + ]); + expected = new Complex128Array([ + 5.0, + 0.0, + 6.0, + 0.0, + 7.0, + 0.0, + 8.0, + 0.0 + ]); + + zcartesianProduct( 0, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + zcartesianProduct( x.length, 0, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride for `x`', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array([ + 1.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0 + ]); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 2, y.length, x, 2, 0, y, 1, 0, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `x`', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array([ + 2.0, + 0.0, + 1.0, + 0.0 + ]); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 2, y.length, x, -1, 1, y, 1, 0, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride for `y`', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array([ + 3.0, + 0.0, + 0.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0 + ]); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( x.length, 2, x, 1, 0, y, 2, 0, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `y`', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array([ + 4.0, + 0.0, + 3.0, + 0.0 + ]); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( x.length, 2, x, 1, 0, y, -1, 1, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride for the output pairs', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 16 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 4, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride for the output pairs', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 2.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 1.0, + 0.0, + 3.0, + 0.0 + ]); + + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, -2, 1, 6 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride for the output pair elements', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 1.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0 + ]); + + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, -1, 1 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `offsetX` parameter', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 2, y.length, x, 1, 1, y, 1, 0, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `offsetY` parameter', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( x.length, 2, x, 1, 0, y, 1, 1, out, 2, 1, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a column-major output layout', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 1, 2, 0 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `offsetOut` parameter', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array([ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + expected = new Complex128Array([ + 0.0, + 0.0, + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 1 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.zcartesian_product.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.zcartesian_product.js new file mode 100644 index 000000000000..253532ceaf21 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.zcartesian_product.js @@ -0,0 +1,756 @@ +/** +* @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 isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var zcartesianProduct = require( './../lib/zcartesian_product.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zcartesianProduct, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', function test( t ) { + t.strictEqual( zcartesianProduct.length, 9, 'has expected arity' ); + t.end(); +}); + +tape( 'the function throws if the first argument is not a valid order', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 1, + 0, + null, + true, + false, + void 0, + [], + {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var out = new Complex128Array( 4 ); + var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + zcartesianProduct( value, x.length, y.length, x, 1, y, 1, out, 2 ); + }; + } +}); + +tape( 'the function throws if the ninth argument is less than max(1,2) (row-major)', function test( t ) { + t.throws( badValue, RangeError, 'throws a range error' ); + t.end(); + + function badValue() { + var out = new Complex128Array( 6 ); + var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0, 5.0, 0.0 ] ); + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 1 ); + } +}); + +tape( 'the function throws if the ninth argument is less than max(1,M*N) (column-major)', function test( t ) { + t.throws( badValue, RangeError, 'throws a range error' ); + t.end(); + + function badValue() { + var out = new Complex128Array( 6 ); + var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0, 5.0, 0.0 ] ); + zcartesianProduct( 'column-major', x.length, y.length, x, 1, y, 1, out, 4 ); + } +}); + +tape( 'the function computes the Cartesian product', function test( t ) { + var expected; + var out; + var x; + var y; + + // Row-major: + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array( [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] ); + + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); + y = new Complex128Array( [ 10.0, 0.0, 20.0, 0.0 ] ); + out = new Complex128Array( 12 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 10.0, + 0.0, + 1.0, + 0.0, + 20.0, + 0.0, + 2.0, + 0.0, + 10.0, + 0.0, + 2.0, + 0.0, + 20.0, + 0.0, + 3.0, + 0.0, + 10.0, + 0.0, + 3.0, + 0.0, + 20.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 5.0, 0.0 ] ); + y = new Complex128Array( [ 7.0, 0.0 ] ); + out = new Complex128Array( 2 ); + expected = new Complex128Array([ + 5.0, + 0.0, + 7.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', 1, 1, x, 1, y, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + // Column-major: + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 2.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', x.length, y.length, x, 1, y, 1, out, 4 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); + y = new Complex128Array( [ 10.0, 0.0, 20.0, 0.0 ] ); + out = new Complex128Array( 12 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 2.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 3.0, + 0.0, + 10.0, + 0.0, + 20.0, + 0.0, + 10.0, + 0.0, + 20.0, + 0.0, + 10.0, + 0.0, + 20.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', x.length, y.length, x, 1, y, 1, out, 6 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 5.0, 0.0 ] ); + y = new Complex128Array( [ 7.0, 0.0 ] ); + out = new Complex128Array( 2 ); + expected = new Complex128Array([ + 5.0, + 0.0, + 7.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', 1, 1, x, 1, y, 1, out, 1 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the output array', function test( t ) { + var out; + var x; + var y; + var z; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + z = zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); + + t.strictEqual( z, out, 'same reference' ); + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + z = zcartesianProduct( 'column-major', x.length, y.length, x, 1, y, 1, out, 4 ); + + t.strictEqual( z, out, 'same reference' ); + + t.end(); +}); + +tape( 'if provided an `M` or `N` parameter equal to `0`, the function returns the output array unchanged', function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array([ + 5.0, + 0.0, + 6.0, + 0.0, + 7.0, + 0.0, + 8.0, + 0.0 + ]); + expected = new Complex128Array([ + 5.0, + 0.0, + 6.0, + 0.0, + 7.0, + 0.0, + 8.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', 0, y.length, x, 1, y, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + zcartesianProduct( 'row-major', x.length, 0, x, 1, y, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + zcartesianProduct( 'column-major', 0, y.length, x, 1, y, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + zcartesianProduct( 'column-major', x.length, 0, x, 1, y, 1, out, 1 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride for `x`', function test( t ) { + var expected; + var out; + var x; + var y; + + // Row-major: + x = new Complex128Array([ + 1.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0 + ]); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', 2, y.length, x, 2, y, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + // Column-major: + x = new Complex128Array([ + 1.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0 + ]); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 2.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', 2, y.length, x, 2, y, 1, out, 4 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `x`', function test( t ) { + var expected; + var out; + var x; + var y; + + // Row-major: + x = new Complex128Array([ + 2.0, + 0.0, + 1.0, + 0.0 + ]); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', 2, y.length, x, -1, y, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + // Column-major: + x = new Complex128Array([ + 2.0, + 0.0, + 1.0, + 0.0 + ]); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 2.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', 2, y.length, x, -1, y, 1, out, 4 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride for `y`', function test( t ) { + var expected; + var out; + var x; + var y; + + // Row-major: + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array([ + 3.0, + 0.0, + 0.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0 + ]); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', x.length, 2, x, 1, y, 2, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + // Column-major: + y = new Complex128Array([ + 3.0, + 0.0, + 0.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0 + ]); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 2.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', x.length, 2, x, 1, y, 2, out, 4 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `y`', function test( t ) { + var expected; + var out; + var x; + var y; + + // Row-major: + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array([ + 4.0, + 0.0, + 3.0, + 0.0 + ]); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', x.length, 2, x, 1, y, -1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + // Column-major: + y = new Complex128Array([ + 4.0, + 0.0, + 3.0, + 0.0 + ]); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 2.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', x.length, 2, x, 1, y, -1, out, 4 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a leading dimension stride for the output array', function test( t ) { + var expected; + var out; + var x; + var y; + + // Row-major: + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 16 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 4 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + // Column-major: + out = new Complex128Array( 16 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 2.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', x.length, y.length, x, 1, y, 1, out, 8 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var expected; + var out; + var x0; + var x1; + var y0; + var y1; + + // Row-major: + x0 = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + y0 = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); + y1 = new Complex128Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); + + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', 2, 2, x1, 1, y1, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + // Column-major: + x0 = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + y0 = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); + y1 = new Complex128Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); + + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 2.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', 2, 2, x1, 1, y1, 1, out, 4 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.zcartesian_product.native.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.zcartesian_product.native.js new file mode 100644 index 000000000000..fc18d5530a80 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.zcartesian_product.native.js @@ -0,0 +1,765 @@ +/** +* @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 isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var zcartesianProduct = tryRequire( resolve( __dirname, './../lib/zcartesian_product.native.js' ) ); +var opts = { + 'skip': ( zcartesianProduct instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zcartesianProduct, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', opts, function test( t ) { + t.strictEqual( zcartesianProduct.length, 9, 'has expected arity' ); + t.end(); +}); + +tape( 'the function throws if the first argument is not a valid order', opts, function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 1, + 0, + null, + true, + false, + void 0, + [], + {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var out = new Complex128Array( 4 ); + var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + zcartesianProduct( value, x.length, y.length, x, 1, y, 1, out, 2 ); + }; + } +}); + +tape( 'the function throws if the ninth argument is less than max(1,2) (row-major)', opts, function test( t ) { + t.throws( badValue, RangeError, 'throws a range error' ); + t.end(); + + function badValue() { + var out = new Complex128Array( 6 ); + var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0, 5.0, 0.0 ] ); + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 1 ); + } +}); + +tape( 'the function throws if the ninth argument is less than max(1,M*N) (column-major)', opts, function test( t ) { + t.throws( badValue, RangeError, 'throws a range error' ); + t.end(); + + function badValue() { + var out = new Complex128Array( 6 ); + var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0, 5.0, 0.0 ] ); + zcartesianProduct( 'column-major', x.length, y.length, x, 1, y, 1, out, 4 ); + } +}); + +tape( 'the function computes the Cartesian product', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + // Row-major: + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array( [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] ); + + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); + y = new Complex128Array( [ 10.0, 0.0, 20.0, 0.0 ] ); + out = new Complex128Array( 12 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 10.0, + 0.0, + 1.0, + 0.0, + 20.0, + 0.0, + 2.0, + 0.0, + 10.0, + 0.0, + 2.0, + 0.0, + 20.0, + 0.0, + 3.0, + 0.0, + 10.0, + 0.0, + 3.0, + 0.0, + 20.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 5.0, 0.0 ] ); + y = new Complex128Array( [ 7.0, 0.0 ] ); + out = new Complex128Array( 2 ); + expected = new Complex128Array([ + 5.0, + 0.0, + 7.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', 1, 1, x, 1, y, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + // Column-major: + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 2.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', x.length, y.length, x, 1, y, 1, out, 4 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); + y = new Complex128Array( [ 10.0, 0.0, 20.0, 0.0 ] ); + out = new Complex128Array( 12 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 2.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 3.0, + 0.0, + 10.0, + 0.0, + 20.0, + 0.0, + 10.0, + 0.0, + 20.0, + 0.0, + 10.0, + 0.0, + 20.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', x.length, y.length, x, 1, y, 1, out, 6 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + x = new Complex128Array( [ 5.0, 0.0 ] ); + y = new Complex128Array( [ 7.0, 0.0 ] ); + out = new Complex128Array( 2 ); + expected = new Complex128Array([ + 5.0, + 0.0, + 7.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', 1, 1, x, 1, y, 1, out, 1 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a reference to the output array', opts, function test( t ) { + var out; + var x; + var y; + var z; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + z = zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); + + t.strictEqual( z, out, 'same reference' ); + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + z = zcartesianProduct( 'column-major', x.length, y.length, x, 1, y, 1, out, 4 ); + + t.strictEqual( z, out, 'same reference' ); + + t.end(); +}); + +tape( 'if provided an `M` or `N` parameter equal to `0`, the function returns the output array unchanged', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array([ + 5.0, + 0.0, + 6.0, + 0.0, + 7.0, + 0.0, + 8.0, + 0.0 + ]); + expected = new Complex128Array([ + 5.0, + 0.0, + 6.0, + 0.0, + 7.0, + 0.0, + 8.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', 0, y.length, x, 1, y, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + zcartesianProduct( 'row-major', x.length, 0, x, 1, y, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + zcartesianProduct( 'column-major', 0, y.length, x, 1, y, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + zcartesianProduct( 'column-major', x.length, 0, x, 1, y, 1, out, 1 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride for `x`', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + // Row-major: + x = new Complex128Array([ + 1.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0 + ]); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', 2, y.length, x, 2, y, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + // Column-major: + x = new Complex128Array([ + 1.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0 + ]); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 2.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', 2, y.length, x, 2, y, 1, out, 4 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `x`', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + // Row-major: + x = new Complex128Array([ + 2.0, + 0.0, + 1.0, + 0.0 + ]); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', 2, y.length, x, -1, y, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + // Column-major: + x = new Complex128Array([ + 2.0, + 0.0, + 1.0, + 0.0 + ]); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 2.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', 2, y.length, x, -1, y, 1, out, 4 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride for `y`', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + // Row-major: + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array([ + 3.0, + 0.0, + 0.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0 + ]); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', x.length, 2, x, 1, y, 2, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + // Column-major: + y = new Complex128Array([ + 3.0, + 0.0, + 0.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0 + ]); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 2.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', x.length, 2, x, 1, y, 2, out, 4 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `y`', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + // Row-major: + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array([ + 4.0, + 0.0, + 3.0, + 0.0 + ]); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', x.length, 2, x, 1, y, -1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + // Column-major: + y = new Complex128Array([ + 4.0, + 0.0, + 3.0, + 0.0 + ]); + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 2.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', x.length, 2, x, 1, y, -1, out, 4 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a leading dimension stride for the output array', opts, function test( t ) { + var expected; + var out; + var x; + var y; + + // Row-major: + x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + out = new Complex128Array( 16 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 4 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + // Column-major: + out = new Complex128Array( 16 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 2.0, + 0.0, + 2.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', x.length, y.length, x, 1, y, 1, out, 8 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var expected; + var out; + var x0; + var x1; + var y0; + var y1; + + // Row-major: + x0 = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + y0 = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); + y1 = new Complex128Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); + + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 3.0, + 0.0, + 1.0, + 0.0, + 4.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 2.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'row-major', 2, 2, x1, 1, y1, 1, out, 2 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + // Column-major: + x0 = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + + y0 = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); + y1 = new Complex128Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); + + out = new Complex128Array( 8 ); + expected = new Complex128Array([ + 1.0, + 0.0, + 1.0, + 0.0, + 2.0, + 0.0, + 2.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0, + 3.0, + 0.0, + 4.0, + 0.0 + ]); + + zcartesianProduct( 'column-major', 2, 2, x1, 1, y1, 1, out, 4 ); + t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); From f73b5f31f969a49d7c5a9c2972d1f444816b8bbb Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sun, 7 Jun 2026 00:30:34 +0500 Subject: [PATCH 02/12] fix: lint error --- 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: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../blas/ext/base/zcartesian-product/benchmark/benchmark.js | 6 +++--- .../base/zcartesian-product/benchmark/benchmark.native.js | 6 +++--- .../base/zcartesian-product/benchmark/benchmark.ndarray.js | 6 +++--- .../benchmark/benchmark.ndarray.native.js | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.js index 549c83020457..62d605d435f7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.js @@ -57,7 +57,7 @@ function createBenchmark( len ) { xbuf = uniform( len*2, -10.0, 10.0, options ); ybuf = uniform( len*2, -10.0, 10.0, options ); - obuf = new Float64Array( len * len * 2 ); + obuf = new Float64Array( len * len * 4 ); x = new Complex128Array( xbuf.buffer ); y = new Complex128Array( ybuf.buffer ); out = new Complex128Array( obuf.buffer ); @@ -75,12 +75,12 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); - if ( isnan( obuf[ i%(len*len*2) ] ) ) { + if ( isnan( obuf[ i%(len*len*4) ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( obuf[ i%(len*len*2) ] ) ) { + if ( isnan( obuf[ i%(len*len*4) ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.native.js index 7fe67ab46c68..f3df7386f6c1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.native.js @@ -62,7 +62,7 @@ function createBenchmark( len ) { xbuf = uniform( len*2, -10.0, 10.0, options ); ybuf = uniform( len*2, -10.0, 10.0, options ); - obuf = new Float64Array( len * len * 2 ); + obuf = new Float64Array( len * len * 4 ); x = new Complex128Array( xbuf.buffer ); y = new Complex128Array( ybuf.buffer ); out = new Complex128Array( obuf.buffer ); @@ -80,12 +80,12 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); - if ( isnan( obuf[ i%(len*len*2) ] ) ) { + if ( isnan( obuf[ i%(len*len*4) ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( obuf[ i%(len*len*2) ] ) ) { + if ( isnan( obuf[ i%(len*len*4) ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.ndarray.js index 02ec3aeddd18..b1390eec4f7c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.ndarray.js @@ -57,7 +57,7 @@ function createBenchmark( len ) { xbuf = uniform( len*2, -10.0, 10.0, options ); ybuf = uniform( len*2, -10.0, 10.0, options ); - obuf = new Float64Array( len * len * 2 ); + obuf = new Float64Array( len * len * 4 ); x = new Complex128Array( xbuf.buffer ); y = new Complex128Array( ybuf.buffer ); out = new Complex128Array( obuf.buffer ); @@ -75,12 +75,12 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // eslint-disable-line max-len - if ( isnan( obuf[ i%(len*len*2) ] ) ) { + if ( isnan( obuf[ i%(len*len*4) ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( obuf[ i%(len*len*2) ] ) ) { + if ( isnan( obuf[ i%(len*len*4) ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.ndarray.native.js index 3547f9334319..4f225fa637fe 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/benchmark.ndarray.native.js @@ -62,7 +62,7 @@ function createBenchmark( len ) { xbuf = uniform( len*2, -10.0, 10.0, options ); ybuf = uniform( len*2, -10.0, 10.0, options ); - obuf = new Float64Array( len * len * 2 ); + obuf = new Float64Array( len * len * 4 ); x = new Complex128Array( xbuf.buffer ); y = new Complex128Array( ybuf.buffer ); out = new Complex128Array( obuf.buffer ); @@ -80,12 +80,12 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // eslint-disable-line max-len - if ( isnan( obuf[ i%(len*len*2) ] ) ) { + if ( isnan( obuf[ i%(len*len*4) ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( obuf[ i%(len*len*2) ] ) ) { + if ( isnan( obuf[ i%(len*len*4) ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); From f243c848a53ddd88e120533c7b0dbf84aa204053 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sun, 7 Jun 2026 00:32:43 +0500 Subject: [PATCH 03/12] fix: lint error --- 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: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: 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: na - task: lint_license_headers status: passed --- --- .../zcartesian-product/benchmark/c/benchmark.length.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/benchmark.length.c index dc02563a7d92..041f3a1ce17b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/benchmark.length.c @@ -97,9 +97,9 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { + const stdlib_complex128_t *x; + const stdlib_complex128_t *y; stdlib_complex128_t *out; - stdlib_complex128_t *x; - stdlib_complex128_t *y; double elapsed; double *obuf; double *xbuf; @@ -143,9 +143,9 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { + const stdlib_complex128_t *x; + const stdlib_complex128_t *y; stdlib_complex128_t *out; - stdlib_complex128_t *x; - stdlib_complex128_t *y; double elapsed; double *obuf; double *xbuf; From 548ee21e292589028f2eb24446631d981130bda0 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Fri, 24 Jul 2026 18:09:17 +0500 Subject: [PATCH 04/12] 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: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: 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 --- --- .../benchmark/c/benchmark.length.c | 68 ++++++++----------- .../ext/base/zcartesian-product/docs/repl.txt | 28 ++++---- .../zcartesian-product/docs/types/test.ts | 2 +- .../lib/zcartesian_product.native.js | 2 +- 4 files changed, 44 insertions(+), 56 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/benchmark.length.c index 041f3a1ce17b..6ae51d8151cb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/benchmark.length.c @@ -97,41 +97,35 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark1( int iterations, int len ) { - const stdlib_complex128_t *x; - const stdlib_complex128_t *y; - stdlib_complex128_t *out; double elapsed; - double *obuf; - double *xbuf; - double *ybuf; + double *x; + double *y; + double *o; double t; int i; - xbuf = (double *) malloc( len * 2 * sizeof( double ) ); - ybuf = (double *) malloc( len * 2 * sizeof( double ) ); - obuf = (double *) malloc( len * len * 4 * sizeof( double ) ); - x = (stdlib_complex128_t *) xbuf; - y = (stdlib_complex128_t *) ybuf; - out = (stdlib_complex128_t *) obuf; + x = (double *) malloc( len * 2 * sizeof( double ) ); + y = (double *) malloc( len * 2 * sizeof( double ) ); + o = (double *) malloc( len * len * 4 * sizeof( double ) ); for ( i = 0; i < len * 2; i++ ) { - xbuf[ i ] = ( rand_double()*200.0 ) - 100.0; - ybuf[ i ] = ( rand_double()*200.0 ) - 100.0; + x[ i ] = ( rand_double()*200.0 ) - 100.0; + y[ i ] = ( rand_double()*200.0 ) - 100.0; } t = tic(); for ( i = 0; i < iterations; i++ ) { - stdlib_strided_zcartesian_product( CblasRowMajor, len, len, x, 1, y, 1, out, 2 ); - if ( obuf[ 0 ] != obuf[ 0 ] ) { + stdlib_strided_zcartesian_product( CblasRowMajor, len, len, (stdlib_complex128_t *)x, 1, (stdlib_complex128_t *)y, 1, (stdlib_complex128_t *)o, 2 ); + if ( o[ 0 ] != o[ 0 ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( obuf[ 0 ] != obuf[ 0 ] ) { + if ( o[ 0 ] != o[ 0 ] ) { printf( "should not return NaN\n" ); } - free( xbuf ); - free( ybuf ); - free( obuf ); + free( x ); + free( y ); + free( o ); return elapsed; } @@ -143,41 +137,35 @@ static double benchmark1( int iterations, int len ) { * @return elapsed time in seconds */ static double benchmark2( int iterations, int len ) { - const stdlib_complex128_t *x; - const stdlib_complex128_t *y; - stdlib_complex128_t *out; double elapsed; - double *obuf; - double *xbuf; - double *ybuf; + double *x; + double *y; + double *o; double t; int i; - xbuf = (double *) malloc( len * 2 * sizeof( double ) ); - ybuf = (double *) malloc( len * 2 * sizeof( double ) ); - obuf = (double *) malloc( len * len * 4 * sizeof( double ) ); - x = (stdlib_complex128_t *) xbuf; - y = (stdlib_complex128_t *) ybuf; - out = (stdlib_complex128_t *) obuf; + x = (double *) malloc( len * 2 * sizeof( double ) ); + y = (double *) malloc( len * 2 * sizeof( double ) ); + o = (double *) malloc( len * len * 4 * sizeof( double ) ); for ( i = 0; i < len * 2; i++ ) { - xbuf[ i ] = ( rand_double()*200.0 ) - 100.0; - ybuf[ i ] = ( rand_double()*200.0 ) - 100.0; + x[ i ] = ( rand_double()*200.0 ) - 100.0; + y[ i ] = ( rand_double()*200.0 ) - 100.0; } t = tic(); for ( i = 0; i < iterations; i++ ) { - stdlib_strided_zcartesian_product_ndarray( len, len, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); - if ( obuf[ 0 ] != obuf[ 0 ] ) { + stdlib_strided_zcartesian_product_ndarray( len, len, (stdlib_complex128_t *)x, 1, 0, (stdlib_complex128_t *)y, 1, 0, (stdlib_complex128_t *)o, 2, 1, 0 ); + if ( o[ 0 ] != o[ 0 ] ) { printf( "should not return NaN\n" ); break; } } elapsed = tic() - t; - if ( obuf[ 0 ] != obuf[ 0 ] ) { + if ( o[ 0 ] != o[ 0 ] ) { printf( "should not return NaN\n" ); } - free( xbuf ); - free( ybuf ); - free( obuf ); + free( x ); + free( y ); + free( o ); return elapsed; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/repl.txt index e4eee18285e5..7032e581623f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/repl.txt @@ -52,18 +52,18 @@ Examples -------- // Standard Usage: - > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 0.0 ] ); - > var y = new {{alias:@stdlib/array/complex128}}( [ 3.0, 0.0, 4.0, 0.0 ] ); + > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 0.0, 2.0, 0.0 ] ); + > var y = new {{alias:@stdlib/array/complex128}}( [ 3.0, 0.0 ] ); > var out = new {{alias:@stdlib/array/complex128}}( 4 ); > {{alias}}( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ) - [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0 ] + [ 1.0, 0.0, 3.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] // Using `M`, `N`, and stride parameters: - > x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 0.0, 2.0, 0.0 ] ); - > y = new {{alias:@stdlib/array/complex128}}( [ 3.0, 0.0, 4.0, 0.0 ] ); + > x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0 ] ); + > y = new {{alias:@stdlib/array/complex128}}( [ 3.0, 0.0 ] ); > out = new {{alias:@stdlib/array/complex128}}( 4 ); - > {{alias}}( 'row-major', 1, 2, x, 2, y, 1, out, 2 ) - [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0 ] + > {{alias}}( 'row-major', 2, 1, x, 2, y, 1, out, 2 ) + [ 1.0, 0.0, 3.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] {{alias}}.ndarray( M, N, x, sx, ox, y, sy, oy, out, so1, so2, oo ) @@ -124,18 +124,18 @@ Examples -------- // Standard Usage: - > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 0.0 ] ); - > var y = new {{alias:@stdlib/array/complex128}}( [ 3.0, 0.0, 4.0, 0.0 ] ); + > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 0.0, 2.0, 0.0 ] ); + > var y = new {{alias:@stdlib/array/complex128}}( [ 3.0, 0.0 ] ); > var out = new {{alias:@stdlib/array/complex128}}( 4 ); > {{alias}}.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ) - [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0 ] + [ 1.0, 0.0, 3.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] // Using an index offset: > x = new {{alias:@stdlib/array/complex128}}( [ 0.0, 0.0, 1.0, 0.0 ] ); - > y = new {{alias:@stdlib/array/complex128}}( [ 3.0, 0.0, 4.0, 0.0 ] ); - > out = new {{alias:@stdlib/array/complex128}}( 4 ); - > {{alias}}.ndarray( 1, 2, x, 1, 1, y, 1, 0, out, 2, 1, 0 ) - [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0 ] + > y = new {{alias:@stdlib/array/complex128}}( [ 3.0, 0.0 ] ); + > out = new {{alias:@stdlib/array/complex128}}( 2 ); + > {{alias}}.ndarray( 1, 1, x, 1, 1, y, 1, 0, out, 2, 1, 0 ) + [ 1.0, 0.0, 3.0, 0.0 ] See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/types/test.ts index 56b0f7ab55df..5e2500f1807f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/types/test.ts @@ -190,7 +190,7 @@ import zcartesianProduct = require( './index' ); zcartesianProduct( 'row-major', x.length, y.length, x, 1, y ); // $ExpectError zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1 ); // $ExpectError zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out ); // $ExpectError - zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2, 1 ); // $ExpectError + zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a Complex128Array... diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.native.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.native.js index 1d44cf7cf488..4ddb2250ff3b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.native.js @@ -79,7 +79,7 @@ function zcartesianProduct( order, M, N, x, strideX, y, strideY, out, LDO ) { xView = reinterpret( x, 0 ); yView = reinterpret( y, 0 ); oView = reinterpret( out, 0 ); - addon( resolveOrder( order ), M, N, xView, strideX, yView, strideY, oView, LDO ); + addon( resolveOrder( order ), M, N, xView, strideX, yView, strideY, oView, LDO ); // eslint-disable-line max-len return out; } From 83449688074901265addc7e3717bfb091a4ad50c Mon Sep 17 00:00:00 2001 From: headlessNode Date: Fri, 24 Jul 2026 20:59:33 +0500 Subject: [PATCH 05/12] 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: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: 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 --- --- .../@stdlib/blas/ext/base/zcartesian-product/README.md | 7 ++++--- .../blas/ext/base/zcartesian-product/examples/index.js | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md index e3142e71185a..586820ec5207 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md @@ -159,6 +159,7 @@ zcartesianProduct.ndarray( 2, 2, x, 1, 1, y, 1, 1, out, 2, 1, 0 ); ```javascript var uniform = require( '@stdlib/random/array/uniform' ); +var logEach = require( '@stdlib/console/log-each' ); var Complex128Array = require( '@stdlib/array/complex128' ); var zcartesianProduct = require( '@stdlib/blas/ext/base/zcartesian-product' ); @@ -166,17 +167,17 @@ var M = 3; var N = 2; var xbuf = uniform( M * 2, -10, 10 ); var x = new Complex128Array( xbuf.buffer ); -console.log( x ); +logEach( '%s', x ); var ybuf = uniform( N * 2, -10, 10 ); var y = new Complex128Array( ybuf.buffer ); -console.log( y ); +logEach( '%s', y ); var out = new Complex128Array( M * N * 2 ); // Compute the Cartesian product: zcartesianProduct( 'row-major', M, N, x, 1, y, 1, out, 2 ); -console.log( out ); +logEach( '%s', out ); ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/index.js index 91319aedf4c9..b9d1220c11cb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/index.js @@ -19,6 +19,7 @@ 'use strict'; var uniform = require( '@stdlib/random/array/uniform' ); +var logEach = require( '@stdlib/console/log-each' ); var Complex128Array = require( '@stdlib/array/complex128' ); var zcartesianProduct = require( './../lib' ); @@ -26,14 +27,14 @@ var M = 3; var N = 2; var xbuf = uniform( M * 2, -10, 10 ); var x = new Complex128Array( xbuf.buffer ); -console.log( x ); +logEach( '%s', x ); var ybuf = uniform( N * 2, -10, 10 ); var y = new Complex128Array( ybuf.buffer ); -console.log( y ); +logEach( '%s', y ); var out = new Complex128Array( M * N * 2 ); // Compute the Cartesian product: zcartesianProduct( 'row-major', M, N, x, 1, y, 1, out, 2 ); -console.log( out ); +logEach( '%s', out ); From de6bddcc0c5aa8bd87a1cfed3fb4c6e3225ee7fc Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sun, 26 Jul 2026 21:18:17 +0500 Subject: [PATCH 06/12] 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: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - 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 --- --- .../ext/base/zcartesian-product/README.md | 54 +- .../benchmark/c/benchmark.length.c | 4 +- .../ext/base/zcartesian-product/docs/repl.txt | 32 +- .../zcartesian-product/docs/types/index.d.ts | 30 +- .../zcartesian-product/examples/c/example.c | 6 +- .../stdlib/blas/ext/base/zcartesian_product.h | 4 +- .../ext/base/zcartesian-product/lib/index.js | 14 +- .../base/zcartesian-product/lib/ndarray.js | 67 +-- .../zcartesian-product/lib/ndarray.native.js | 18 +- .../lib/zcartesian_product.js | 8 +- .../lib/zcartesian_product.native.js | 8 +- .../ext/base/zcartesian-product/package.json | 5 +- .../ext/base/zcartesian-product/src/main.c | 48 +- .../zcartesian-product/test/test.ndarray.js | 416 +++++++------- .../test/test.ndarray.native.js | 416 +++++++------- .../test/test.zcartesian_product.js | 517 +++++++++--------- .../test/test.zcartesian_product.native.js | 494 ++++++++--------- 17 files changed, 1075 insertions(+), 1066 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md index 586820ec5207..2e962adf41e8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md @@ -20,7 +20,7 @@ limitations under the License. # zcartesianProduct -> Compute the Cartesian product for two double-precision complex strided arrays. +> Compute the Cartesian product for two double-precision complex floating-point strided arrays.
@@ -32,18 +32,18 @@ var zcartesianProduct = require( '@stdlib/blas/ext/base/zcartesian-product' ); #### zcartesianProduct( order, M, N, x, strideX, y, strideY, out, LDO ) -Computes the Cartesian product for two double-precision complex strided arrays. +Computes the Cartesian product for two double-precision complex floating-point strided arrays. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); -var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); var out = new Complex128Array( 8 ); // Compute the Cartesian product: zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); -// out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +// out => [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] ``` The function has the following parameters: @@ -63,13 +63,13 @@ The `M`, `N` and stride parameters determine which elements in the strided array ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var x = new Complex128Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0 ] ); -var y = new Complex128Array( [ 3.0, 0.0, 0.0, 0.0, 4.0, 0.0 ] ); +var x = new Complex128Array( [ 1.0, 2.0, 9.0, 10.0, 3.0, 4.0 ] ); +var y = new Complex128Array( [ 5.0, 6.0, 11.0, 12.0, 7.0, 8.0 ] ); var out = new Complex128Array( 8 ); // Compute the Cartesian product of every other element: zcartesianProduct( 'row-major', 2, 2, x, 2, y, 2, out, 2 ); -// out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +// out => [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.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. @@ -78,8 +78,8 @@ Note that indexing is relative to the first index. To introduce an offset, use [ var Complex128Array = require( '@stdlib/array/complex128' ); // Initial arrays... -var x0 = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); -var y0 = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); +var x0 = new Complex128Array( [ 9.0, 10.0, 1.0, 2.0, 3.0, 4.0 ] ); +var y0 = new Complex128Array( [ 11.0, 12.0, 5.0, 6.0, 7.0, 8.0 ] ); // Create offset views... var x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element @@ -89,7 +89,7 @@ var out = new Complex128Array( 8 ); // Compute the Cartesian product: zcartesianProduct( 'row-major', 2, 2, x1, 1, y1, 1, out, 2 ); -// out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +// out => [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] ``` @@ -98,18 +98,18 @@ zcartesianProduct( 'row-major', 2, 2, x1, 1, y1, 1, out, 2 ); -Computes the Cartesian product for two double-precision complex strided arrays using alternative indexing semantics. +Computes the Cartesian product for two double-precision complex floating-point strided arrays using alternative indexing semantics. ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); -var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); var out = new Complex128Array( 8 ); // Compute the Cartesian product: zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); -// out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +// out => [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] ``` The function has the following additional parameters: @@ -125,13 +125,13 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Complex128Array = require( '@stdlib/array/complex128' ); -var x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); -var y = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); +var x = new Complex128Array( [ 9.0, 10.0, 1.0, 2.0, 3.0, 4.0 ] ); +var y = new Complex128Array( [ 11.0, 12.0, 5.0, 6.0, 7.0, 8.0 ] ); var out = new Complex128Array( 8 ); // Compute the Cartesian product: zcartesianProduct.ndarray( 2, 2, x, 1, 1, y, 1, 1, out, 2, 1, 0 ); -// out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +// out => [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] ```
@@ -216,13 +216,13 @@ logEach( '%s', out ); -Computes the Cartesian product for two double-precision complex strided arrays. +Computes the Cartesian product for two double-precision complex floating-point strided arrays. ```c #include "stdlib/complex/float64/ctor.h" -double x[] = { 1.0, 0.0, 2.0, 0.0 }; -double y[] = { 3.0, 0.0, 4.0, 0.0 }; +double x[] = { 1.0, 2.0, 3.0, 4.0 }; +double y[] = { 5.0, 6.0, 7.0, 8.0 }; double out[ 16 ]; stdlib_strided_zcartesian_product( CblasRowMajor, 2, 2, (stdlib_complex128_t *)x, 1, (stdlib_complex128_t *)y, 1, (stdlib_complex128_t *)out, 2 ); @@ -250,13 +250,13 @@ void stdlib_strided_zcartesian_product( const CBLAS_LAYOUT order, const CBLAS_IN -Computes the Cartesian product for two double-precision complex strided arrays using alternative indexing semantics. +Computes the Cartesian product for two double-precision complex floating-point strided arrays using alternative indexing semantics. ```c #include "stdlib/complex/float64/ctor.h" -double x[] = { 1.0, 0.0, 2.0, 0.0 }; -double y[] = { 3.0, 0.0, 4.0, 0.0 }; +double x[] = { 1.0, 2.0, 3.0, 4.0 }; +double y[] = { 5.0, 6.0, 7.0, 8.0 }; double out[ 16 ]; stdlib_strided_zcartesian_product_ndarray( 2, 2, (stdlib_complex128_t *)x, 1, 0, (stdlib_complex128_t *)y, 1, 0, (stdlib_complex128_t *)out, 2, 1, 0 ); @@ -307,8 +307,8 @@ void stdlib_strided_zcartesian_product_ndarray( const CBLAS_INT M, const CBLAS_I int main( void ) { // Create strided input arrays (interleaved real and imaginary components): - double X[] = { 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0 }; - double Y[] = { 5.0, 0.0, 6.0, 0.0, 7.0, 0.0, 8.0, 0.0 }; + double X[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + double Y[] = { 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 }; // Specify the number of indexed elements: const int M = 4; @@ -326,7 +326,7 @@ int main( void ) { stdlib_strided_zcartesian_product( CblasRowMajor, M, N, (stdlib_complex128_t *)X, strideX, (stdlib_complex128_t *)Y, strideY, (stdlib_complex128_t *)out, LDO ); // Print the result: - for ( int i = 0; i < M*N; i++ ) { + for ( int i = 0; i < M*N*2; i++ ) { printf( "out[ %i ] = ( %lf, %lf )\n", i, out[ i*2 ], out[ (i*2)+1 ] ); } } diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/benchmark.length.c index 6ae51d8151cb..b4b112f88b30 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/benchmark/c/benchmark.length.c @@ -190,14 +190,14 @@ int main( void ) { iter = ITERATIONS / (int) pow( 10, i-1 ); for ( j = 0; j < REPEATS; j++ ) { count += 1; - printf( "# c::%s:len=%d\n", NAME, len ); + printf( "# c::native::%s:len=%d\n", NAME, len ); elapsed = benchmark1( iter, len ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } for ( j = 0; j < REPEATS; j++ ) { count += 1; - printf( "# c::%s:ndarray:len=%d\n", NAME, len ); + printf( "# c::native::%s:ndarray:len=%d\n", NAME, len ); elapsed = benchmark2( iter, len ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/repl.txt index 7032e581623f..0b962b05e791 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( order, M, N, x, strideX, y, strideY, out, LDO ) - Computes the Cartesian product for two double-precision complex strided - arrays. + Computes the Cartesian product for two double-precision complex floating- + point strided arrays. The `M`, `N`, and stride parameters determine which elements in the strided arrays are accessed at runtime. @@ -52,23 +52,23 @@ Examples -------- // Standard Usage: - > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 0.0, 2.0, 0.0 ] ); - > var y = new {{alias:@stdlib/array/complex128}}( [ 3.0, 0.0 ] ); + > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var y = new {{alias:@stdlib/array/complex128}}( [ 5.0, 6.0 ] ); > var out = new {{alias:@stdlib/array/complex128}}( 4 ); > {{alias}}( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ) - [ 1.0, 0.0, 3.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] + [ 1.0, 2.0, 5.0, 6.0, 3.0, 4.0, 5.0, 6.0 ] // Using `M`, `N`, and stride parameters: - > x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0 ] ); - > y = new {{alias:@stdlib/array/complex128}}( [ 3.0, 0.0 ] ); + > x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 7.0, 8.0, 3.0, 4.0 ] ); + > y = new {{alias:@stdlib/array/complex128}}( [ 5.0, 6.0 ] ); > out = new {{alias:@stdlib/array/complex128}}( 4 ); > {{alias}}( 'row-major', 2, 1, x, 2, y, 1, out, 2 ) - [ 1.0, 0.0, 3.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] + [ 1.0, 2.0, 5.0, 6.0, 3.0, 4.0, 5.0, 6.0 ] {{alias}}.ndarray( M, N, x, sx, ox, y, sy, oy, out, so1, so2, oo ) - Computes the Cartesian product for two double-precision complex strided - arrays using alternative indexing semantics. + Computes the Cartesian product for two double-precision complex floating- + point strided arrays using alternative indexing semantics. Pairs are stored as rows in the output matrix, where the first column contains the first element of each pair and the second column contains @@ -124,18 +124,18 @@ Examples -------- // Standard Usage: - > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 0.0, 2.0, 0.0 ] ); - > var y = new {{alias:@stdlib/array/complex128}}( [ 3.0, 0.0 ] ); + > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var y = new {{alias:@stdlib/array/complex128}}( [ 5.0, 6.0 ] ); > var out = new {{alias:@stdlib/array/complex128}}( 4 ); > {{alias}}.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ) - [ 1.0, 0.0, 3.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] + [ 1.0, 2.0, 5.0, 6.0, 3.0, 4.0, 5.0, 6.0 ] // Using an index offset: - > x = new {{alias:@stdlib/array/complex128}}( [ 0.0, 0.0, 1.0, 0.0 ] ); - > y = new {{alias:@stdlib/array/complex128}}( [ 3.0, 0.0 ] ); + > x = new {{alias:@stdlib/array/complex128}}( [ 7.0, 8.0, 1.0, 2.0 ] ); + > y = new {{alias:@stdlib/array/complex128}}( [ 5.0, 6.0 ] ); > out = new {{alias:@stdlib/array/complex128}}( 2 ); > {{alias}}.ndarray( 1, 1, x, 1, 1, y, 1, 0, out, 2, 1, 0 ) - [ 1.0, 0.0, 3.0, 0.0 ] + [ 1.0, 2.0, 5.0, 6.0 ] See Also -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/types/index.d.ts index e851dc068b96..088de59c5a46 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/types/index.d.ts @@ -28,7 +28,7 @@ import { Complex128Array } from '@stdlib/types/array'; */ interface Routine { /** - * Computes the Cartesian product for two double-precision complex strided arrays. + * Computes the Cartesian product for two double-precision complex floating-point strided arrays. * * ## Notes * @@ -48,17 +48,17 @@ interface Routine { * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * - * var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - * var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + * var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * var y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); * var out = new Complex128Array( 8 ); * * zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); - * // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] + * // out => [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] */ ( order: Layout, M: number, N: number, x: Complex128Array, strideX: number, y: Complex128Array, strideY: number, out: Complex128Array, LDO: number ): Complex128Array; /** - * Computes the Cartesian product for two double-precision complex strided arrays using alternative indexing semantics. + * Computes the Cartesian product for two double-precision complex floating-point strided arrays using alternative indexing semantics. * * ## Notes * @@ -81,18 +81,18 @@ interface Routine { * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * - * var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - * var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + * var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * var y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); * var out = new Complex128Array( 8 ); * * zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); - * // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] + * // out => [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] */ ndarray( M: number, N: number, x: Complex128Array, strideX: number, offsetX: number, y: Complex128Array, strideY: number, offsetY: number, out: Complex128Array, strideOut1: number, strideOut2: number, offsetOut: number ): Complex128Array; } /** -* Computes the Cartesian product for two double-precision complex strided arrays. +* Computes the Cartesian product for two double-precision complex floating-point strided arrays. * * ## Notes * @@ -112,22 +112,22 @@ interface Routine { * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * -* var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); -* var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); * var out = new Complex128Array( 8 ); * * zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); -* // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +* // out => [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * -* var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); -* var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); * var out = new Complex128Array( 8 ); * * zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); -* // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +* // out => [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] */ declare var zcartesianProduct: Routine; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/c/example.c index 0062ec39eff1..050e693992bc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/c/example.c @@ -23,8 +23,8 @@ int main( void ) { // Create strided input arrays (interleaved real and imaginary components): - double X[] = { 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0 }; - double Y[] = { 5.0, 0.0, 6.0, 0.0, 7.0, 0.0, 8.0, 0.0 }; + double X[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + double Y[] = { 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 }; // Specify the number of indexed elements: const int M = 4; @@ -42,7 +42,7 @@ int main( void ) { stdlib_strided_zcartesian_product( CblasRowMajor, M, N, (stdlib_complex128_t *)X, strideX, (stdlib_complex128_t *)Y, strideY, (stdlib_complex128_t *)out, LDO ); // Print the result: - for ( int i = 0; i < M*N; i++ ) { + for ( int i = 0; i < M*N*2; i++ ) { printf( "out[ %i ] = ( %lf, %lf )\n", i, out[ i*2 ], out[ (i*2)+1 ] ); } } diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/include/stdlib/blas/ext/base/zcartesian_product.h b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/include/stdlib/blas/ext/base/zcartesian_product.h index 0e06cd94efdc..455b65f2c9de 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/include/stdlib/blas/ext/base/zcartesian_product.h +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/include/stdlib/blas/ext/base/zcartesian_product.h @@ -30,12 +30,12 @@ extern "C" { #endif /** -* Computes the Cartesian product for two double-precision complex strided arrays. +* Computes the Cartesian product for two double-precision complex floating-point strided arrays. */ void API_SUFFIX(stdlib_strided_zcartesian_product)( const CBLAS_LAYOUT order, const CBLAS_INT M, const CBLAS_INT N, const stdlib_complex128_t *X, const CBLAS_INT strideX, const stdlib_complex128_t *Y, const CBLAS_INT strideY, stdlib_complex128_t *Out, const CBLAS_INT LDO ); /** -* Computes the Cartesian product for two double-precision complex strided arrays using alternative indexing semantics. +* Computes the Cartesian product for two double-precision complex floating-point strided arrays using alternative indexing semantics. */ void API_SUFFIX(stdlib_strided_zcartesian_product_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const stdlib_complex128_t *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const stdlib_complex128_t *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, stdlib_complex128_t *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/index.js index 2a9e8e33409a..cd332b4f52a9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Compute the Cartesian product for two double-precision complex strided arrays. +* Compute the Cartesian product for two double-precision complex floating-point strided arrays. * * @module @stdlib/blas/ext/base/zcartesian-product * @@ -27,23 +27,23 @@ * var Complex128Array = require( '@stdlib/array/complex128' ); * var zcartesianProduct = require( '@stdlib/blas/ext/base/zcartesian-product' ); * -* var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); -* var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); * var out = new Complex128Array( 8 ); * * zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); -* // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +* // out => [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * var zcartesianProduct = require( '@stdlib/blas/ext/base/zcartesian-product' ); * -* var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); -* var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); * var out = new Complex128Array( 8 ); * * zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); -* // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +* // out => [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] */ // MODULES // diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js index 98f953ddbf60..5711e63b6541 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js @@ -24,15 +24,12 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); -var zfill = require( '@stdlib/blas/ext/base/zfill' ).ndarray; -var zcopy = require( '@stdlib/blas/base/zcopy' ).ndarray; -var Complex128 = require( '@stdlib/complex/float64/ctor' ); // MAIN // /** -* Computes the Cartesian product for two double-precision complex strided arrays using alternative indexing semantics. +* Computes the Cartesian product for two double-precision complex floating-point strided arrays using alternative indexing semantics. * * ## Notes * @@ -55,26 +52,25 @@ var Complex128 = require( '@stdlib/complex/float64/ctor' ); * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * -* var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); -* var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); * var out = new Complex128Array( 8 ); * * zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); -* // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +* // out => [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] */ function zcartesianProduct( M, N, x, strideX, offsetX, y, strideY, offsetY, out, strideOut1, strideOut2, offsetOut ) { // eslint-disable-line max-len var xView; var yView; var oView; + var so1; + var so2; var sx; var sy; - var s1; - var s2; - var ox; - var oy; - var oo; - var iy; + var re; + var im; var ix; + var iy; var io; var i; var j; @@ -90,39 +86,48 @@ function zcartesianProduct( M, N, x, strideX, offsetX, y, strideY, offsetY, out, // Adjusted strides and offsets for reinterpreted arrays: sx = strideX * 2; sy = strideY * 2; - s1 = strideOut1 * 2; - s2 = strideOut2 * 2; - ox = offsetX * 2; - oy = offsetY * 2; - oo = offsetOut * 2; - - ix = ox; - io = oo; + so1 = strideOut1 * 2; + so2 = strideOut2 * 2; + ix = offsetX * 2; + iy = offsetY * 2; + io = offsetOut * 2; if ( isRowMajor( [ strideOut1, strideOut2 ] ) ) { for ( i = 0; i < M; i++ ) { - iy = oy; + iy = offsetY * 2; for ( j = 0; j < N; j++ ) { oView[ io ] = xView[ ix ]; oView[ io + 1 ] = xView[ ix + 1 ]; - oView[ io + s2 ] = yView[ iy ]; - oView[ io + s2 + 1 ] = yView[ iy + 1 ]; + oView[ io + so2 ] = yView[ iy ]; + oView[ io + so2 + 1 ] = yView[ iy + 1 ]; iy += sy; - io += s1; + io += so1; } ix += sx; } return out; } // Column-major... - io = offsetOut; + ix = offsetX * 2; + io = offsetOut * 2; for ( i = 0; i < M; i++ ) { - zfill( N, new Complex128( xView[ ox + (i*sx) ], xView[ ox + (i*sx) + 1 ] ), out, strideOut1, io ); // eslint-disable-line max-len - io += N * strideOut1; + re = xView[ ix ]; + im = xView[ ix + 1 ]; + for ( j = 0; j < N; j++ ) { + oView[ io ] = re; + oView[ io + 1 ] = im; + io += so1; + } + ix += sx; } - io = offsetOut + strideOut2; + io = ( offsetOut * 2 ) + so2; for ( i = 0; i < M; i++ ) { - zcopy( N, y, strideY, offsetY, out, strideOut1, io ); - io += N * strideOut1; + iy = offsetY * 2; + for ( j = 0; j < N; j++ ) { + oView[ io ] = yView[ iy ]; + oView[ io + 1 ] = yView[ iy + 1 ]; + iy += sy; + io += so1; + } } return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.native.js index 992edb217f2f..ddbf8828dad4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.native.js @@ -29,7 +29,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Computes the Cartesian product for two double-precision complex strided arrays using alternative indexing semantics. +* Computes the Cartesian product for two double-precision complex floating-point strided arrays using alternative indexing semantics. * * ## Notes * @@ -52,17 +52,21 @@ var addon = require( './../src/addon.node' ); * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * -* var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); -* var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); * var out = new Complex128Array( 8 ); * * zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); -* // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +* // out => [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] */ function zcartesianProduct( M, N, x, strideX, offsetX, y, strideY, offsetY, out, strideOut1, strideOut2, offsetOut ) { - var xView = reinterpret( x, 0 ); - var yView = reinterpret( y, 0 ); - var oView = reinterpret( out, 0 ); + var xView; + var yView; + var oView; + + xView = reinterpret( x, 0 ); + yView = reinterpret( y, 0 ); + oView = reinterpret( out, 0 ); addon.ndarray( M, N, xView, strideX, offsetX, yView, strideY, offsetY, oView, strideOut1, strideOut2, offsetOut ); return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.js index 8c9c26bc7b6a..db2861638b8e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.js @@ -31,7 +31,7 @@ var ndarray = require( './ndarray.js' ); // MAIN // /** -* Computes the Cartesian product for two double-precision complex strided arrays. +* Computes the Cartesian product for two double-precision complex floating-point strided arrays. * * ## Notes * @@ -53,12 +53,12 @@ var ndarray = require( './ndarray.js' ); * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * -* var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); -* var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); * var out = new Complex128Array( 8 ); * * zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); -* // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +* // out => [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] */ function zcartesianProduct( order, M, N, x, strideX, y, strideY, out, LDO ) { var sa1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.native.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.native.js index 4ddb2250ff3b..cf62c765a83c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/zcartesian_product.native.js @@ -32,7 +32,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Computes the Cartesian product for two double-precision complex strided arrays. +* Computes the Cartesian product for two double-precision complex floating-point strided arrays. * * ## Notes * @@ -54,12 +54,12 @@ var addon = require( './../src/addon.node' ); * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * -* var x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); -* var y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); +* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); * var out = new Complex128Array( 8 ); * * zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); -* // out => [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] +* // out => [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] */ function zcartesianProduct( order, M, N, x, strideX, y, strideY, out, LDO ) { var xView; diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/package.json b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/package.json index b530f944f217..401cb959058e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/ext/base/zcartesian-product", "version": "0.0.0", - "description": "Compute the Cartesian product for two double-precision complex strided arrays.", + "description": "Compute the Cartesian product for two double-precision complex floating-point strided arrays.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -64,9 +64,8 @@ "strided", "array", "ndarray", - "complex128", "complex", - "double-precision", + "complex128", "complex128array" ], "__stdlib__": { diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/main.c index e3551962dc7f..1a3bb8edf14d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/main.c @@ -25,7 +25,7 @@ #include "stdlib/complex/float64/ctor.h" /** -* Computes the Cartesian product for two double-precision complex strided arrays. +* Computes the Cartesian product for two double-precision complex floating-point strided arrays. * * ## Notes * @@ -60,7 +60,7 @@ void API_SUFFIX(stdlib_strided_zcartesian_product)( const CBLAS_LAYOUT order, co } /** -* Computes the Cartesian product for two double-precision complex strided arrays using alternative indexing semantics. +* Computes the Cartesian product for two double-precision complex floating-point strided arrays using alternative indexing semantics. * * ## Notes * @@ -80,62 +80,40 @@ void API_SUFFIX(stdlib_strided_zcartesian_product)( const CBLAS_LAYOUT order, co * @param offsetOut starting index for Out */ void API_SUFFIX(stdlib_strided_zcartesian_product_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const stdlib_complex128_t *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const stdlib_complex128_t *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, stdlib_complex128_t *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ) { - const double *xView = (double *)X; - const double *yView = (double *)Y; - double *oView = (double *)Out; - int64_t sa[ 2 ]; CBLAS_INT isrm; - CBLAS_INT sx; - CBLAS_INT sy; - CBLAS_INT s1; - CBLAS_INT s2; + int64_t sa[ 2 ]; CBLAS_INT iy; CBLAS_INT ix; CBLAS_INT io; - CBLAS_INT ox; - CBLAS_INT oy; - CBLAS_INT oo; CBLAS_INT i; CBLAS_INT j; if ( M <= 0 || N <= 0 ) { return; } - - // Adjusted strides and offsets for reinterpreted arrays: - sx = strideX * 2; - sy = strideY * 2; - s1 = strideOut1 * 2; - s2 = strideOut2 * 2; - ox = offsetX * 2; - oy = offsetY * 2; - oo = offsetOut * 2; - sa[ 0 ] = strideOut1; sa[ 1 ] = strideOut2; isrm = stdlib_ndarray_is_row_major( 2, sa ); - ix = ox; - io = oo; + ix = offsetX; + io = offsetOut; if ( isrm ) { for ( i = 0; i < M; i++ ) { - iy = oy; + iy = offsetY; for ( j = 0; j < N; j++ ) { - oView[ io ] = xView[ ix ]; - oView[ io + 1 ] = xView[ ix + 1 ]; - oView[ io + s2 ] = yView[ iy ]; - oView[ io + s2 + 1 ] = yView[ iy + 1 ]; - iy += sy; - io += s1; + Out[ io ] = X[ ix ]; + Out[ io + strideOut2 ] = Y[ iy ]; + iy += strideY; + io += strideOut1; } - ix += sx; + ix += strideX; } return; } // Column-major... - io = offsetOut; for ( i = 0; i < M; i++ ) { - API_SUFFIX(stdlib_strided_zfill_ndarray)( N, stdlib_complex128( xView[ ox + (i*sx) ], xView[ ox + (i*sx) + 1 ] ), Out, strideOut1, io ); + API_SUFFIX(stdlib_strided_zfill_ndarray)( N, X[ ix ], Out, strideOut1, io ); io += N * strideOut1; + ix += strideX; } io = offsetOut + strideOut2; for ( i = 0; i < M; i++ ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.ndarray.js index 1db38b5ba45a..38cc62b591dc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.ndarray.js @@ -46,59 +46,59 @@ tape( 'the function computes the Cartesian product', function test( t ) { var y; // Row-major: - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - y = new Complex128Array( [ 10.0, 0.0, 20.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + y = new Complex128Array( [ 7.0, 8.0, 9.0, 10.0 ] ); out = new Complex128Array( 12 ); expected = new Complex128Array([ 1.0, - 0.0, - 10.0, - 0.0, + 2.0, + 7.0, + 8.0, 1.0, - 0.0, - 20.0, - 0.0, 2.0, - 0.0, + 9.0, 10.0, - 0.0, - 2.0, - 0.0, - 20.0, - 0.0, 3.0, - 0.0, - 10.0, - 0.0, + 4.0, + 7.0, + 8.0, 3.0, - 0.0, - 20.0, - 0.0 + 4.0, + 9.0, + 10.0, + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 9.0, + 10.0 ]); zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); @@ -113,8 +113,8 @@ tape( 'the function returns a reference to the output array', function test( t ) var y; var z; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); z = zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); @@ -128,27 +128,27 @@ tape( 'if provided an `M` or `N` parameter equal to `0`, the function returns th var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array([ - 5.0, - 0.0, - 6.0, - 0.0, - 7.0, - 0.0, - 8.0, - 0.0 + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0 ]); expected = new Complex128Array([ - 5.0, - 0.0, - 6.0, - 0.0, - 7.0, - 0.0, - 8.0, - 0.0 + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0 ]); zcartesianProduct( 0, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); @@ -168,33 +168,33 @@ tape( 'the function supports specifying a stride for `x`', function test( t ) { x = new Complex128Array([ 1.0, - 0.0, - 0.0, - 0.0, 2.0, 0.0, 0.0, + 3.0, + 4.0, + 0.0, 0.0 ]); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( 2, y.length, x, 2, 0, y, 1, 0, out, 2, 1, 0 ); @@ -211,29 +211,29 @@ tape( 'the function supports specifying a negative stride for `x`', function tes x = new Complex128Array([ 2.0, - 0.0, + 4.0, 1.0, - 0.0 + 2.0 ]); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, - 3.0, - 0.0, + 7.0, + 8.0, 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 2.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( 2, y.length, x, -1, 1, y, 1, 0, out, 2, 1, 0 ); @@ -248,35 +248,35 @@ tape( 'the function supports specifying a stride for `y`', function test( t ) { var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); y = new Complex128Array([ - 3.0, - 0.0, - 0.0, + 5.0, + 6.0, 0.0, - 4.0, 0.0, + 7.0, + 8.0, 0.0, 0.0 ]); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( x.length, 2, x, 1, 0, y, 2, 0, out, 2, 1, 0 ); @@ -291,31 +291,31 @@ tape( 'the function supports specifying a negative stride for `y`', function tes var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); y = new Complex128Array([ - 4.0, - 0.0, - 3.0, - 0.0 + 7.0, + 8.0, + 5.0, + 6.0 ]); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( x.length, 2, x, 1, 0, y, -1, 1, out, 2, 1, 0 ); @@ -330,38 +330,38 @@ tape( 'the function supports specifying a stride for the output pairs', function var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 16 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 0.0, 0.0, 0.0, 0.0, 1.0, - 0.0, - 4.0, - 0.0, - 0.0, + 2.0, + 7.0, + 8.0, 0.0, 0.0, 0.0, - 2.0, 0.0, 3.0, + 4.0, + 5.0, + 6.0, 0.0, 0.0, 0.0, 0.0, - 0.0, - 2.0, - 0.0, + 3.0, 4.0, - 0.0, + 7.0, + 8.0, 0.0, 0.0, 0.0, @@ -380,26 +380,26 @@ tape( 'the function supports specifying a negative stride for the output pairs', var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ - 2.0, - 0.0, + 3.0, 4.0, - 0.0, - 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 1.0, - 0.0, 4.0, - 0.0, + 5.0, + 6.0, 1.0, - 0.0, - 3.0, - 0.0 + 2.0, + 7.0, + 8.0, + 1.0, + 2.0, + 5.0, + 6.0 ]); zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, -2, 1, 6 ); @@ -414,26 +414,26 @@ tape( 'the function supports specifying a negative stride for the output pair el var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ - 3.0, - 0.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, + 2.0, + 7.0, + 8.0, 1.0, - 0.0, - 3.0, - 0.0, 2.0, - 0.0, + 5.0, + 6.0, + 3.0, 4.0, - 0.0, - 2.0, - 0.0 + 7.0, + 8.0, + 3.0, + 4.0 ]); zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, -1, 1 ); @@ -448,26 +448,26 @@ tape( 'the function supports an `offsetX` parameter', function test( t ) { var x; var y; - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( 2, y.length, x, 1, 1, y, 1, 0, out, 2, 1, 0 ); @@ -482,26 +482,26 @@ tape( 'the function supports an `offsetY` parameter', function test( t ) { var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( x.length, 2, x, 1, 0, y, 1, 1, out, 2, 1, 0 ); @@ -516,29 +516,29 @@ tape( 'the function supports a column-major output layout', function test( t ) { var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, + 2.0, 1.0, - 0.0, + 2.0, 3.0, - 0.0, 4.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0 + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 7.0, + 8.0 ]); - zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 1, 2, 0 ); + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 1, 4, 0 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); t.end(); @@ -550,8 +550,8 @@ tape( 'the function supports an `offsetOut` parameter', function test( t ) { var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array([ 0.0, 0.0, @@ -576,21 +576,21 @@ tape( 'the function supports an `offsetOut` parameter', function test( t ) { 0.0, 0.0, 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.ndarray.native.js index 17497168caff..9421b23b7697 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.ndarray.native.js @@ -55,59 +55,59 @@ tape( 'the function computes the Cartesian product', opts, function test( t ) { var y; // Row-major: - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - y = new Complex128Array( [ 10.0, 0.0, 20.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + y = new Complex128Array( [ 7.0, 8.0, 9.0, 10.0 ] ); out = new Complex128Array( 12 ); expected = new Complex128Array([ 1.0, - 0.0, - 10.0, - 0.0, + 2.0, + 7.0, + 8.0, 1.0, - 0.0, - 20.0, - 0.0, 2.0, - 0.0, + 9.0, 10.0, - 0.0, - 2.0, - 0.0, - 20.0, - 0.0, 3.0, - 0.0, - 10.0, - 0.0, + 4.0, + 7.0, + 8.0, 3.0, - 0.0, - 20.0, - 0.0 + 4.0, + 9.0, + 10.0, + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 9.0, + 10.0 ]); zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); @@ -122,8 +122,8 @@ tape( 'the function returns a reference to the output array', opts, function tes var y; var z; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); z = zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); @@ -137,27 +137,27 @@ tape( 'if provided an `M` or `N` parameter equal to `0`, the function returns th var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array([ - 5.0, - 0.0, - 6.0, - 0.0, - 7.0, - 0.0, - 8.0, - 0.0 + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0 ]); expected = new Complex128Array([ - 5.0, - 0.0, - 6.0, - 0.0, - 7.0, - 0.0, - 8.0, - 0.0 + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0 ]); zcartesianProduct( 0, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); @@ -177,33 +177,33 @@ tape( 'the function supports specifying a stride for `x`', opts, function test( x = new Complex128Array([ 1.0, - 0.0, - 0.0, - 0.0, 2.0, 0.0, 0.0, + 3.0, + 4.0, + 0.0, 0.0 ]); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( 2, y.length, x, 2, 0, y, 1, 0, out, 2, 1, 0 ); @@ -220,29 +220,29 @@ tape( 'the function supports specifying a negative stride for `x`', opts, functi x = new Complex128Array([ 2.0, - 0.0, + 4.0, 1.0, - 0.0 + 2.0 ]); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, - 3.0, - 0.0, + 7.0, + 8.0, 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 2.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( 2, y.length, x, -1, 1, y, 1, 0, out, 2, 1, 0 ); @@ -257,35 +257,35 @@ tape( 'the function supports specifying a stride for `y`', opts, function test( var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); y = new Complex128Array([ - 3.0, - 0.0, - 0.0, + 5.0, + 6.0, 0.0, - 4.0, 0.0, + 7.0, + 8.0, 0.0, 0.0 ]); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( x.length, 2, x, 1, 0, y, 2, 0, out, 2, 1, 0 ); @@ -300,31 +300,31 @@ tape( 'the function supports specifying a negative stride for `y`', opts, functi var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); y = new Complex128Array([ - 4.0, - 0.0, - 3.0, - 0.0 + 7.0, + 8.0, + 5.0, + 6.0 ]); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( x.length, 2, x, 1, 0, y, -1, 1, out, 2, 1, 0 ); @@ -339,38 +339,38 @@ tape( 'the function supports specifying a stride for the output pairs', opts, fu var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 16 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 0.0, 0.0, 0.0, 0.0, 1.0, - 0.0, - 4.0, - 0.0, - 0.0, + 2.0, + 7.0, + 8.0, 0.0, 0.0, 0.0, - 2.0, 0.0, 3.0, + 4.0, + 5.0, + 6.0, 0.0, 0.0, 0.0, 0.0, - 0.0, - 2.0, - 0.0, + 3.0, 4.0, - 0.0, + 7.0, + 8.0, 0.0, 0.0, 0.0, @@ -389,26 +389,26 @@ tape( 'the function supports specifying a negative stride for the output pairs', var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ - 2.0, - 0.0, + 3.0, 4.0, - 0.0, - 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 1.0, - 0.0, 4.0, - 0.0, + 5.0, + 6.0, 1.0, - 0.0, - 3.0, - 0.0 + 2.0, + 7.0, + 8.0, + 1.0, + 2.0, + 5.0, + 6.0 ]); zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, -2, 1, 6 ); @@ -423,26 +423,26 @@ tape( 'the function supports specifying a negative stride for the output pair el var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ - 3.0, - 0.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, + 2.0, + 7.0, + 8.0, 1.0, - 0.0, - 3.0, - 0.0, 2.0, - 0.0, + 5.0, + 6.0, + 3.0, 4.0, - 0.0, - 2.0, - 0.0 + 7.0, + 8.0, + 3.0, + 4.0 ]); zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, -1, 1 ); @@ -457,26 +457,26 @@ tape( 'the function supports an `offsetX` parameter', opts, function test( t ) { var x; var y; - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( 2, y.length, x, 1, 1, y, 1, 0, out, 2, 1, 0 ); @@ -491,26 +491,26 @@ tape( 'the function supports an `offsetY` parameter', opts, function test( t ) { var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( x.length, 2, x, 1, 0, y, 1, 1, out, 2, 1, 0 ); @@ -525,29 +525,29 @@ tape( 'the function supports a column-major output layout', opts, function test( var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, + 2.0, 1.0, - 0.0, + 2.0, 3.0, - 0.0, 4.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0 + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 7.0, + 8.0 ]); - zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 1, 2, 0 ); + zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 1, 4, 0 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); t.end(); @@ -559,8 +559,8 @@ tape( 'the function supports an `offsetOut` parameter', opts, function test( t ) var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array([ 0.0, 0.0, @@ -585,21 +585,21 @@ tape( 'the function supports an `offsetOut` parameter', opts, function test( t ) 0.0, 0.0, 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.zcartesian_product.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.zcartesian_product.js index 253532ceaf21..1f8c8b378b1e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.zcartesian_product.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.zcartesian_product.js @@ -101,127 +101,144 @@ tape( 'the function computes the Cartesian product', function test( t ) { var y; // Row-major: - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); - expected = new Complex128Array( [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] ); + expected = new Complex128Array([ + 1.0, + 2.0, + 5.0, + 6.0, + 1.0, + 2.0, + 7.0, + 8.0, + 3.0, + 4.0, + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 + ]); zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - y = new Complex128Array( [ 10.0, 0.0, 20.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + y = new Complex128Array( [ 7.0, 8.0, 9.0, 10.0 ] ); out = new Complex128Array( 12 ); expected = new Complex128Array([ 1.0, - 0.0, - 10.0, - 0.0, + 2.0, + 7.0, + 8.0, 1.0, - 0.0, - 20.0, - 0.0, 2.0, - 0.0, + 9.0, 10.0, - 0.0, - 2.0, - 0.0, - 20.0, - 0.0, 3.0, - 0.0, - 10.0, - 0.0, + 4.0, + 7.0, + 8.0, 3.0, - 0.0, - 20.0, - 0.0 + 4.0, + 9.0, + 10.0, + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 9.0, + 10.0 ]); zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); - x = new Complex128Array( [ 5.0, 0.0 ] ); - y = new Complex128Array( [ 7.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0 ] ); + y = new Complex128Array( [ 5.0, 6.0 ] ); out = new Complex128Array( 2 ); expected = new Complex128Array([ + 1.0, + 2.0, 5.0, - 0.0, - 7.0, - 0.0 + 6.0 ]); zcartesianProduct( 'row-major', 1, 1, x, 1, y, 1, out, 2 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); // Column-major: - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 1.0, - 0.0, 2.0, - 0.0, + 1.0, 2.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 7.0, + 8.0 ]); zcartesianProduct( 'column-major', x.length, y.length, x, 1, y, 1, out, 4 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - y = new Complex128Array( [ 10.0, 0.0, 20.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + y = new Complex128Array( [ 7.0, 8.0, 9.0, 10.0 ] ); out = new Complex128Array( 12 ); expected = new Complex128Array([ 1.0, - 0.0, - 1.0, - 0.0, 2.0, - 0.0, + 1.0, 2.0, - 0.0, 3.0, - 0.0, + 4.0, 3.0, - 0.0, - 10.0, - 0.0, - 20.0, - 0.0, + 4.0, + 5.0, + 6.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, 10.0, - 0.0, - 20.0, - 0.0, + 7.0, + 8.0, + 9.0, 10.0, - 0.0, - 20.0, - 0.0 + 7.0, + 8.0, + 9.0, + 10.0 ]); zcartesianProduct( 'column-major', x.length, y.length, x, 1, y, 1, out, 6 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); - x = new Complex128Array( [ 5.0, 0.0 ] ); - y = new Complex128Array( [ 7.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0 ] ); + y = new Complex128Array( [ 5.0, 6.0 ] ); out = new Complex128Array( 2 ); expected = new Complex128Array([ + 1.0, + 2.0, 5.0, - 0.0, - 7.0, - 0.0 + 6.0 ]); zcartesianProduct( 'column-major', 1, 1, x, 1, y, 1, out, 1 ); @@ -236,15 +253,15 @@ tape( 'the function returns a reference to the output array', function test( t ) var y; var z; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); z = zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); t.strictEqual( z, out, 'same reference' ); - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); z = zcartesianProduct( 'column-major', x.length, y.length, x, 1, y, 1, out, 4 ); @@ -259,27 +276,27 @@ tape( 'if provided an `M` or `N` parameter equal to `0`, the function returns th var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array([ - 5.0, - 0.0, - 6.0, - 0.0, - 7.0, - 0.0, - 8.0, - 0.0 + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0 ]); expected = new Complex128Array([ - 5.0, - 0.0, - 6.0, - 0.0, - 7.0, - 0.0, - 8.0, - 0.0 + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0 ]); zcartesianProduct( 'row-major', 0, y.length, x, 1, y, 1, out, 2 ); @@ -306,33 +323,33 @@ tape( 'the function supports specifying a stride for `x`', function test( t ) { // Row-major: x = new Complex128Array([ 1.0, - 0.0, - 0.0, - 0.0, 2.0, 0.0, 0.0, + 3.0, + 4.0, + 0.0, 0.0 ]); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( 'row-major', 2, y.length, x, 2, y, 1, out, 2 ); @@ -341,32 +358,33 @@ tape( 'the function supports specifying a stride for `x`', function test( t ) { // Column-major: x = new Complex128Array([ 1.0, - 0.0, - 0.0, - 0.0, 2.0, 0.0, 0.0, + 3.0, + 4.0, + 0.0, 0.0 ]); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 1.0, - 0.0, 2.0, - 0.0, + 1.0, 2.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 7.0, + 8.0 ]); zcartesianProduct( 'column-major', 2, y.length, x, 2, y, 1, out, 4 ); @@ -384,29 +402,29 @@ tape( 'the function supports specifying a negative stride for `x`', function tes // Row-major: x = new Complex128Array([ 2.0, - 0.0, + 4.0, 1.0, - 0.0 + 2.0 ]); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, - 3.0, - 0.0, + 7.0, + 8.0, 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 2.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( 'row-major', 2, y.length, x, -1, y, 1, out, 2 ); @@ -415,28 +433,29 @@ tape( 'the function supports specifying a negative stride for `x`', function tes // Column-major: x = new Complex128Array([ 2.0, - 0.0, + 4.0, 1.0, - 0.0 + 2.0 ]); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, + 2.0, 1.0, - 0.0, 2.0, - 0.0, 2.0, - 0.0, - 3.0, - 0.0, 4.0, - 0.0, - 3.0, - 0.0, + 2.0, 4.0, - 0.0 + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 7.0, + 8.0 ]); zcartesianProduct( 'column-major', 2, y.length, x, -1, y, 1, out, 4 ); @@ -452,69 +471,70 @@ tape( 'the function supports specifying a stride for `y`', function test( t ) { var y; // Row-major: - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); y = new Complex128Array([ - 3.0, - 0.0, - 0.0, + 5.0, + 6.0, 0.0, - 4.0, 0.0, + 7.0, + 8.0, 0.0, 0.0 ]); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( 'row-major', x.length, 2, x, 1, y, 2, out, 2 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); // Column-major: + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); y = new Complex128Array([ - 3.0, - 0.0, - 0.0, + 5.0, + 6.0, 0.0, - 4.0, 0.0, + 7.0, + 8.0, 0.0, 0.0 ]); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 1.0, - 0.0, 2.0, - 0.0, + 1.0, 2.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 7.0, + 8.0 ]); zcartesianProduct( 'column-major', x.length, 2, x, 1, y, 2, out, 4 ); @@ -530,61 +550,62 @@ tape( 'the function supports specifying a negative stride for `y`', function tes var y; // Row-major: - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); y = new Complex128Array([ - 4.0, - 0.0, - 3.0, - 0.0 + 7.0, + 8.0, + 5.0, + 6.0 ]); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( 'row-major', x.length, 2, x, 1, y, -1, out, 2 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); // Column-major: + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); y = new Complex128Array([ - 4.0, - 0.0, - 3.0, - 0.0 + 7.0, + 8.0, + 5.0, + 6.0 ]); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 1.0, - 0.0, 2.0, - 0.0, + 1.0, 2.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 7.0, + 8.0 ]); zcartesianProduct( 'column-major', x.length, 2, x, 1, y, -1, out, 4 ); @@ -600,38 +621,38 @@ tape( 'the function supports specifying a leading dimension stride for the outpu var y; // Row-major: - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 16 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 0.0, 0.0, 0.0, 0.0, 1.0, - 0.0, - 4.0, - 0.0, - 0.0, + 2.0, + 7.0, + 8.0, 0.0, 0.0, 0.0, - 2.0, 0.0, 3.0, + 4.0, + 5.0, + 6.0, 0.0, 0.0, 0.0, 0.0, - 0.0, - 2.0, - 0.0, + 3.0, 4.0, - 0.0, + 7.0, + 8.0, 0.0, 0.0, 0.0, @@ -642,15 +663,18 @@ tape( 'the function supports specifying a leading dimension stride for the outpu t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); // Column-major: + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 16 ); expected = new Complex128Array([ 1.0, - 0.0, - 1.0, - 0.0, 2.0, - 0.0, + 1.0, 2.0, + 3.0, + 4.0, + 3.0, + 4.0, 0.0, 0.0, 0.0, @@ -659,15 +683,14 @@ tape( 'the function supports specifying a leading dimension stride for the outpu 0.0, 0.0, 0.0, - 0.0, - 3.0, - 0.0, - 4.0, - 0.0, - 3.0, - 0.0, - 4.0, - 0.0, + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 7.0, + 8.0, 0.0, 0.0, 0.0, @@ -693,60 +716,60 @@ tape( 'the function supports view offsets', function test( t ) { var y1; // Row-major: - x0 = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + x0 = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] ); x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - y0 = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); + y0 = new Complex128Array( [ 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] ); y1 = new Complex128Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( 'row-major', 2, 2, x1, 1, y1, 1, out, 2 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); // Column-major: - x0 = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + x0 = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] ); x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - y0 = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); + y0 = new Complex128Array( [ 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] ); y1 = new Complex128Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 1.0, - 0.0, 2.0, - 0.0, + 1.0, 2.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 7.0, + 8.0 ]); zcartesianProduct( 'column-major', 2, 2, x1, 1, y1, 1, out, 4 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.zcartesian_product.native.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.zcartesian_product.native.js index fc18d5530a80..9cd9d4d1947f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.zcartesian_product.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/test/test.zcartesian_product.native.js @@ -110,127 +110,127 @@ tape( 'the function computes the Cartesian product', opts, function test( t ) { var y; // Row-major: - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); - expected = new Complex128Array( [ 1.0, 0.0, 3.0, 0.0, 1.0, 0.0, 4.0, 0.0, 2.0, 0.0, 3.0, 0.0, 2.0, 0.0, 4.0, 0.0 ] ); + expected = new Complex128Array( [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] ); zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - y = new Complex128Array( [ 10.0, 0.0, 20.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + y = new Complex128Array( [ 7.0, 8.0, 9.0, 10.0 ] ); out = new Complex128Array( 12 ); expected = new Complex128Array([ 1.0, - 0.0, - 10.0, - 0.0, + 2.0, + 7.0, + 8.0, 1.0, - 0.0, - 20.0, - 0.0, 2.0, - 0.0, + 9.0, 10.0, - 0.0, - 2.0, - 0.0, - 20.0, - 0.0, 3.0, - 0.0, - 10.0, - 0.0, + 4.0, + 7.0, + 8.0, 3.0, - 0.0, - 20.0, - 0.0 + 4.0, + 9.0, + 10.0, + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 9.0, + 10.0 ]); zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); - x = new Complex128Array( [ 5.0, 0.0 ] ); - y = new Complex128Array( [ 7.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0 ] ); + y = new Complex128Array( [ 5.0, 6.0 ] ); out = new Complex128Array( 2 ); expected = new Complex128Array([ + 1.0, + 2.0, 5.0, - 0.0, - 7.0, - 0.0 + 6.0 ]); zcartesianProduct( 'row-major', 1, 1, x, 1, y, 1, out, 2 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); // Column-major: - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 1.0, - 0.0, 2.0, - 0.0, + 1.0, 2.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 7.0, + 8.0 ]); zcartesianProduct( 'column-major', x.length, y.length, x, 1, y, 1, out, 4 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - y = new Complex128Array( [ 10.0, 0.0, 20.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + y = new Complex128Array( [ 7.0, 8.0, 9.0, 10.0 ] ); out = new Complex128Array( 12 ); expected = new Complex128Array([ 1.0, - 0.0, - 1.0, - 0.0, 2.0, - 0.0, + 1.0, 2.0, - 0.0, 3.0, - 0.0, + 4.0, 3.0, - 0.0, - 10.0, - 0.0, - 20.0, - 0.0, + 4.0, + 5.0, + 6.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, 10.0, - 0.0, - 20.0, - 0.0, + 7.0, + 8.0, + 9.0, 10.0, - 0.0, - 20.0, - 0.0 + 7.0, + 8.0, + 9.0, + 10.0 ]); zcartesianProduct( 'column-major', x.length, y.length, x, 1, y, 1, out, 6 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); - x = new Complex128Array( [ 5.0, 0.0 ] ); - y = new Complex128Array( [ 7.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0 ] ); + y = new Complex128Array( [ 5.0, 6.0 ] ); out = new Complex128Array( 2 ); expected = new Complex128Array([ + 1.0, + 2.0, 5.0, - 0.0, - 7.0, - 0.0 + 6.0 ]); zcartesianProduct( 'column-major', 1, 1, x, 1, y, 1, out, 1 ); @@ -245,15 +245,15 @@ tape( 'the function returns a reference to the output array', opts, function tes var y; var z; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); z = zcartesianProduct( 'row-major', x.length, y.length, x, 1, y, 1, out, 2 ); t.strictEqual( z, out, 'same reference' ); - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); z = zcartesianProduct( 'column-major', x.length, y.length, x, 1, y, 1, out, 4 ); @@ -268,27 +268,27 @@ tape( 'if provided an `M` or `N` parameter equal to `0`, the function returns th var x; var y; - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array([ - 5.0, - 0.0, - 6.0, - 0.0, - 7.0, - 0.0, - 8.0, - 0.0 + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0 ]); expected = new Complex128Array([ - 5.0, - 0.0, - 6.0, - 0.0, - 7.0, - 0.0, - 8.0, - 0.0 + 9.0, + 10.0, + 11.0, + 12.0, + 13.0, + 14.0, + 15.0, + 16.0 ]); zcartesianProduct( 'row-major', 0, y.length, x, 1, y, 1, out, 2 ); @@ -315,33 +315,33 @@ tape( 'the function supports specifying a stride for `x`', opts, function test( // Row-major: x = new Complex128Array([ 1.0, - 0.0, - 0.0, - 0.0, 2.0, 0.0, 0.0, + 3.0, + 4.0, + 0.0, 0.0 ]); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( 'row-major', 2, y.length, x, 2, y, 1, out, 2 ); @@ -350,32 +350,32 @@ tape( 'the function supports specifying a stride for `x`', opts, function test( // Column-major: x = new Complex128Array([ 1.0, - 0.0, - 0.0, - 0.0, 2.0, 0.0, 0.0, + 3.0, + 4.0, + 0.0, 0.0 ]); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 1.0, - 0.0, 2.0, - 0.0, + 1.0, 2.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 7.0, + 8.0 ]); zcartesianProduct( 'column-major', 2, y.length, x, 2, y, 1, out, 4 ); @@ -393,29 +393,29 @@ tape( 'the function supports specifying a negative stride for `x`', opts, functi // Row-major: x = new Complex128Array([ 2.0, - 0.0, + 4.0, 1.0, - 0.0 + 2.0 ]); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, - 3.0, - 0.0, + 7.0, + 8.0, 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 2.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( 'row-major', 2, y.length, x, -1, y, 1, out, 2 ); @@ -424,28 +424,28 @@ tape( 'the function supports specifying a negative stride for `x`', opts, functi // Column-major: x = new Complex128Array([ 2.0, - 0.0, + 4.0, 1.0, - 0.0 + 2.0 ]); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, + 2.0, 1.0, - 0.0, 2.0, - 0.0, 2.0, - 0.0, - 3.0, - 0.0, 4.0, - 0.0, - 3.0, - 0.0, + 2.0, 4.0, - 0.0 + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 7.0, + 8.0 ]); zcartesianProduct( 'column-major', 2, y.length, x, -1, y, 1, out, 4 ); @@ -461,35 +461,35 @@ tape( 'the function supports specifying a stride for `y`', opts, function test( var y; // Row-major: - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); y = new Complex128Array([ - 3.0, - 0.0, - 0.0, + 5.0, + 6.0, 0.0, - 4.0, 0.0, + 7.0, + 8.0, 0.0, 0.0 ]); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( 'row-major', x.length, 2, x, 1, y, 2, out, 2 ); @@ -497,33 +497,33 @@ tape( 'the function supports specifying a stride for `y`', opts, function test( // Column-major: y = new Complex128Array([ - 3.0, - 0.0, - 0.0, + 5.0, + 6.0, 0.0, - 4.0, 0.0, + 7.0, + 8.0, 0.0, 0.0 ]); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 1.0, - 0.0, 2.0, - 0.0, + 1.0, 2.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 7.0, + 8.0 ]); zcartesianProduct( 'column-major', x.length, 2, x, 1, y, 2, out, 4 ); @@ -539,31 +539,31 @@ tape( 'the function supports specifying a negative stride for `y`', opts, functi var y; // Row-major: - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); y = new Complex128Array([ - 4.0, - 0.0, - 3.0, - 0.0 + 7.0, + 8.0, + 5.0, + 6.0 ]); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( 'row-major', x.length, 2, x, 1, y, -1, out, 2 ); @@ -571,29 +571,29 @@ tape( 'the function supports specifying a negative stride for `y`', opts, functi // Column-major: y = new Complex128Array([ - 4.0, - 0.0, - 3.0, - 0.0 + 7.0, + 8.0, + 5.0, + 6.0 ]); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 1.0, - 0.0, 2.0, - 0.0, + 1.0, 2.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 7.0, + 8.0 ]); zcartesianProduct( 'column-major', x.length, 2, x, 1, y, -1, out, 4 ); @@ -609,38 +609,38 @@ tape( 'the function supports specifying a leading dimension stride for the outpu var y; // Row-major: - x = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0 ] ); - y = new Complex128Array( [ 3.0, 0.0, 4.0, 0.0 ] ); + x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + y = new Complex128Array( [ 5.0, 6.0, 7.0, 8.0 ] ); out = new Complex128Array( 16 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 0.0, 0.0, 0.0, 0.0, 1.0, - 0.0, - 4.0, - 0.0, - 0.0, + 2.0, + 7.0, + 8.0, 0.0, 0.0, 0.0, - 2.0, 0.0, 3.0, + 4.0, + 5.0, + 6.0, 0.0, 0.0, 0.0, 0.0, - 0.0, - 2.0, - 0.0, + 3.0, 4.0, - 0.0, + 7.0, + 8.0, 0.0, 0.0, 0.0, @@ -654,12 +654,13 @@ tape( 'the function supports specifying a leading dimension stride for the outpu out = new Complex128Array( 16 ); expected = new Complex128Array([ 1.0, - 0.0, - 1.0, - 0.0, 2.0, - 0.0, + 1.0, 2.0, + 3.0, + 4.0, + 3.0, + 4.0, 0.0, 0.0, 0.0, @@ -668,15 +669,14 @@ tape( 'the function supports specifying a leading dimension stride for the outpu 0.0, 0.0, 0.0, - 0.0, - 3.0, - 0.0, - 4.0, - 0.0, - 3.0, - 0.0, - 4.0, - 0.0, + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 7.0, + 8.0, 0.0, 0.0, 0.0, @@ -702,60 +702,60 @@ tape( 'the function supports view offsets', opts, function test( t ) { var y1; // Row-major: - x0 = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + x0 = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] ); x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - y0 = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); + y0 = new Complex128Array( [ 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] ); y1 = new Complex128Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 3.0, - 0.0, + 2.0, + 5.0, + 6.0, 1.0, - 0.0, - 4.0, - 0.0, 2.0, - 0.0, + 7.0, + 8.0, 3.0, - 0.0, - 2.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 3.0, + 4.0, + 7.0, + 8.0 ]); zcartesianProduct( 'row-major', 2, 2, x1, 1, y1, 1, out, 2 ); t.strictEqual( isSameComplex128Array( out, expected ), true, 'returns expected value' ); // Column-major: - x0 = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + x0 = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] ); x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - y0 = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); + y0 = new Complex128Array( [ 0.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] ); y1 = new Complex128Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); out = new Complex128Array( 8 ); expected = new Complex128Array([ 1.0, - 0.0, - 1.0, - 0.0, 2.0, - 0.0, + 1.0, 2.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0, 3.0, - 0.0, 4.0, - 0.0 + 5.0, + 6.0, + 7.0, + 8.0, + 5.0, + 6.0, + 7.0, + 8.0 ]); zcartesianProduct( 'column-major', 2, 2, x1, 1, y1, 1, out, 4 ); From 45b41005518f60cb137c00426467072a012385b0 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 26 Jul 2026 19:53:51 -0700 Subject: [PATCH 07/12] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../blas/ext/base/zcartesian-product/docs/repl.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/repl.txt index 0b962b05e791..9aec1df2843d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/docs/repl.txt @@ -131,11 +131,11 @@ [ 1.0, 2.0, 5.0, 6.0, 3.0, 4.0, 5.0, 6.0 ] // Using an index offset: - > x = new {{alias:@stdlib/array/complex128}}( [ 7.0, 8.0, 1.0, 2.0 ] ); + > x = new {{alias:@stdlib/array/complex128}}( [ 7.0, 8.0, 1.0, 2.0, 3.0, 4.0 ] ); > y = new {{alias:@stdlib/array/complex128}}( [ 5.0, 6.0 ] ); - > out = new {{alias:@stdlib/array/complex128}}( 2 ); - > {{alias}}.ndarray( 1, 1, x, 1, 1, y, 1, 0, out, 2, 1, 0 ) - [ 1.0, 2.0, 5.0, 6.0 ] + > out = new {{alias:@stdlib/array/complex128}}( 4 ); + > {{alias}}.ndarray( 2, 1, x, 1, 1, y, 1, 0, out, 2, 1, 0 ) + [ 1.0, 2.0, 5.0, 6.0, 3.0, 4.0, 5.0, 6.0 ] See Also -------- From 80778787b1341f777afcee92edbbc197fac57b3e Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 26 Jul 2026 19:56:34 -0700 Subject: [PATCH 08/12] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../blas/ext/base/zcartesian-product/README.md | 14 +++++++------- .../base/zcartesian-product/examples/c/example.c | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md index 2e962adf41e8..d799df9391e8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md @@ -221,8 +221,8 @@ Computes the Cartesian product for two double-precision complex floating-point s ```c #include "stdlib/complex/float64/ctor.h" -double x[] = { 1.0, 2.0, 3.0, 4.0 }; -double y[] = { 5.0, 6.0, 7.0, 8.0 }; +const double x[] = { 1.0, 2.0, 3.0, 4.0 }; +const double y[] = { 5.0, 6.0, 7.0, 8.0 }; double out[ 16 ]; stdlib_strided_zcartesian_product( CblasRowMajor, 2, 2, (stdlib_complex128_t *)x, 1, (stdlib_complex128_t *)y, 1, (stdlib_complex128_t *)out, 2 ); @@ -255,8 +255,8 @@ Computes the Cartesian product for two double-precision complex floating-point s ```c #include "stdlib/complex/float64/ctor.h" -double x[] = { 1.0, 2.0, 3.0, 4.0 }; -double y[] = { 5.0, 6.0, 7.0, 8.0 }; +const double x[] = { 1.0, 2.0, 3.0, 4.0 }; +const double y[] = { 5.0, 6.0, 7.0, 8.0 }; double out[ 16 ]; stdlib_strided_zcartesian_product_ndarray( 2, 2, (stdlib_complex128_t *)x, 1, 0, (stdlib_complex128_t *)y, 1, 0, (stdlib_complex128_t *)out, 2, 1, 0 ); @@ -307,8 +307,8 @@ void stdlib_strided_zcartesian_product_ndarray( const CBLAS_INT M, const CBLAS_I int main( void ) { // Create strided input arrays (interleaved real and imaginary components): - double X[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; - double Y[] = { 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 }; + const double X[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + const double Y[] = { 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 }; // Specify the number of indexed elements: const int M = 4; @@ -323,7 +323,7 @@ int main( void ) { const int LDO = 2; // Compute the Cartesian product: - stdlib_strided_zcartesian_product( CblasRowMajor, M, N, (stdlib_complex128_t *)X, strideX, (stdlib_complex128_t *)Y, strideY, (stdlib_complex128_t *)out, LDO ); + stdlib_strided_zcartesian_product( CblasRowMajor, M, N, (const stdlib_complex128_t *)X, strideX, (const stdlib_complex128_t *)Y, strideY, (stdlib_complex128_t *)out, LDO ); // Print the result: for ( int i = 0; i < M*N*2; i++ ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/c/example.c index 050e693992bc..8e3028621f59 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/examples/c/example.c @@ -23,8 +23,8 @@ int main( void ) { // Create strided input arrays (interleaved real and imaginary components): - double X[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; - double Y[] = { 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 }; + const double X[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + const double Y[] = { 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 }; // Specify the number of indexed elements: const int M = 4; @@ -39,7 +39,7 @@ int main( void ) { const int LDO = 2; // Compute the Cartesian product: - stdlib_strided_zcartesian_product( CblasRowMajor, M, N, (stdlib_complex128_t *)X, strideX, (stdlib_complex128_t *)Y, strideY, (stdlib_complex128_t *)out, LDO ); + stdlib_strided_zcartesian_product( CblasRowMajor, M, N, (const stdlib_complex128_t *)X, strideX, (const stdlib_complex128_t *)Y, strideY, (stdlib_complex128_t *)out, LDO ); // Print the result: for ( int i = 0; i < M*N*2; i++ ) { From affdcfce6520d86638e4a9e0aaeaf04e27b26b40 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 26 Jul 2026 20:03:30 -0700 Subject: [PATCH 09/12] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js index 5711e63b6541..9ea22408d05f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js @@ -83,7 +83,7 @@ function zcartesianProduct( M, N, x, strideX, offsetX, y, strideY, offsetY, out, yView = reinterpret( y, 0 ); oView = reinterpret( out, 0 ); - // Adjusted strides and offsets for reinterpreted arrays: + // Adjust strides and offsets according to the real-valued arrays: sx = strideX * 2; sy = strideY * 2; so1 = strideOut1 * 2; @@ -107,6 +107,8 @@ function zcartesianProduct( M, N, x, strideX, offsetX, y, strideY, offsetY, out, return out; } // Column-major... + + // Fill the first column with each element repeated `N` times... ix = offsetX * 2; io = offsetOut * 2; for ( i = 0; i < M; i++ ) { @@ -119,6 +121,7 @@ function zcartesianProduct( M, N, x, strideX, offsetX, y, strideY, offsetY, out, } ix += sx; } + // Fill the second column by repeating the second input array `M` times... io = ( offsetOut * 2 ) + so2; for ( i = 0; i < M; i++ ) { iy = offsetY * 2; From df834c948271a19a0e16e7d23960267379d16700 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 26 Jul 2026 20:04:08 -0700 Subject: [PATCH 10/12] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js index 9ea22408d05f..d03d3050fb17 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/lib/ndarray.js @@ -108,7 +108,7 @@ function zcartesianProduct( M, N, x, strideX, offsetX, y, strideY, offsetY, out, } // Column-major... - // Fill the first column with each element repeated `N` times... + // Fill the first column with each element from the first input array repeated `N` times... ix = offsetX * 2; io = offsetOut * 2; for ( i = 0; i < M; i++ ) { From e7e1ee506b93aae0d0636aa4d754e62ab787035b Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 26 Jul 2026 20:05:56 -0700 Subject: [PATCH 11/12] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/zcartesian-product/src/main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/main.c index 1a3bb8edf14d..cad1cefa494b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/src/main.c @@ -80,8 +80,7 @@ void API_SUFFIX(stdlib_strided_zcartesian_product)( const CBLAS_LAYOUT order, co * @param offsetOut starting index for Out */ void API_SUFFIX(stdlib_strided_zcartesian_product_ndarray)( const CBLAS_INT M, const CBLAS_INT N, const stdlib_complex128_t *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const stdlib_complex128_t *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, stdlib_complex128_t *Out, const CBLAS_INT strideOut1, const CBLAS_INT strideOut2, const CBLAS_INT offsetOut ) { - CBLAS_INT isrm; - int64_t sa[ 2 ]; + CBLAS_INT sa[ 2 ]; CBLAS_INT iy; CBLAS_INT ix; CBLAS_INT io; @@ -93,10 +92,9 @@ void API_SUFFIX(stdlib_strided_zcartesian_product_ndarray)( const CBLAS_INT M, c } sa[ 0 ] = strideOut1; sa[ 1 ] = strideOut2; - isrm = stdlib_ndarray_is_row_major( 2, sa ); ix = offsetX; io = offsetOut; - if ( isrm ) { + if ( stdlib_ndarray_is_row_major( 2, sa ) ) { for ( i = 0; i < M; i++ ) { iy = offsetY; for ( j = 0; j < N; j++ ) { From d9048d79272745a0dddf324c5e97f605710c7ea0 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 26 Jul 2026 20:10:43 -0700 Subject: [PATCH 12/12] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/zcartesian-product/README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md index d799df9391e8..c6065fbe2c4d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/zcartesian-product/README.md @@ -112,10 +112,17 @@ zcartesianProduct.ndarray( x.length, y.length, x, 1, 0, y, 1, 0, out, 2, 1, 0 ); // out => [ 1.0, 2.0, 5.0, 6.0, 1.0, 2.0, 7.0, 8.0, 3.0, 4.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] ``` -The function has the following additional parameters: +The function has the following parameters: +- **M**: number of indexed elements in `x`. +- **N**: number of indexed elements in `y`. +- **x**: first input [`Complex128Array`][@stdlib/array/complex128]. +- **strideX**: stride length for `x`. - **offsetX**: starting index for `x`. +- **y**: second input [`Complex128Array`][@stdlib/array/complex128]. +- **strideY**: stride length for `y`. - **offsetY**: starting index for `y`. +- **out**: output [`Complex128Array`][@stdlib/array/complex128]. - **strideOut1**: stride length for the first dimension of `out`. - **strideOut2**: stride length for the second dimension of `out`. - **offsetOut**: starting index for `out`.