From c5c1625fe9ed66df019bac67d4a3e670166421e6 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Thu, 16 Jan 2025 09:28:33 +0000 Subject: [PATCH 1/2] feat: add blas/base/cdotu --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/blas/base/cdotu/README.md | 246 +++++++++++++++++ .../blas/base/cdotu/benchmark/benchmark.js | 107 ++++++++ .../base/cdotu/benchmark/benchmark.ndarray.js | 107 ++++++++ .../blas/base/cdotu/docs/types/index.d.ts | 140 ++++++++++ .../blas/base/cdotu/docs/types/test.ts | 249 ++++++++++++++++++ .../@stdlib/blas/base/cdotu/examples/index.js | 37 +++ .../@stdlib/blas/base/cdotu/lib/cdotu.js | 65 +++++ .../@stdlib/blas/base/cdotu/lib/index.js | 86 ++++++ .../@stdlib/blas/base/cdotu/lib/main.js | 35 +++ .../@stdlib/blas/base/cdotu/lib/ndarray.js | 82 ++++++ .../@stdlib/blas/base/cdotu/package.json | 82 ++++++ .../blas/base/cdotu/test/test.cdotu.js | 217 +++++++++++++++ .../@stdlib/blas/base/cdotu/test/test.js | 82 ++++++ .../blas/base/cdotu/test/test.ndarray.js | 239 +++++++++++++++++ 14 files changed, 1774 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/cdotu/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/cdotu/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/cdotu/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/cdotu/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/cdotu/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/cdotu/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/cdotu/lib/cdotu.js create mode 100644 lib/node_modules/@stdlib/blas/base/cdotu/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/cdotu/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/cdotu/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/cdotu/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/cdotu/test/test.cdotu.js create mode 100644 lib/node_modules/@stdlib/blas/base/cdotu/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/cdotu/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/base/cdotu/README.md b/lib/node_modules/@stdlib/blas/base/cdotu/README.md new file mode 100644 index 000000000000..8e9b31b33f8c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cdotu/README.md @@ -0,0 +1,246 @@ + + +# cdotu + +> Calculate the [dot product][dot-product] of two single-precision complex floating-point vectors. + +
+ +The [dot product][dot-product] (or scalar product) is defined as + + + +```math +\mathbf{zx}\cdot\mathbf{zy} = \sum_{i=0}^{N-1} zx_i zy_i = zx_0 zy_0 + zx_1 zy_1 + \ldots + zx_{N-1} zy_{N-1} +``` + + + +
+ + + +
+ +## Usage + +```javascript +var cdotu = require( '@stdlib/blas/base/cdotu' ); +``` + +#### cdotu( N, zx, strideX, zy, strideY ) + +Calculates the dot product of vectors `zx` and `zy`. + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); +var real = require( '@stdlib/complex/float32/real' ); +var imag = require( '@stdlib/complex/float32/imag' ); + +var zx = new Complex64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); +var zy = new Complex64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); + +var z = cdotu( 3, zx, 1, zy, 1 ); +// returns + +var re = real( z ); +// returns -52.0 + +var im = imag( z ); +// returns 82.0 +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **zx**: input [`Complex64Array`][@stdlib/array/complex64]. +- **strideX**: index increment for `zx`. +- **zy**: input [`Complex64Array`][@stdlib/array/complex64]. +- **strideY**: index increment for `zy`. + +The `N` and strides parameters determine which elements in the strided arrays are accessed at runtime. For example, to calculate the dot product of every other value in `zx` and the first `N` elements of `zy` in reverse order, + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); +var real = require( '@stdlib/complex/float32/real' ); +var imag = require( '@stdlib/complex/float32/imag' ); + +var zx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var zy = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + +var z = cdotu( 2, zx, 2, zy, -1 ); +// returns + +var re = real( z ); +// returns -2.0 + +var im = imag( z ); +// returns 14.0 +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); +var real = require( '@stdlib/complex/float32/real' ); +var imag = require( '@stdlib/complex/float32/imag' ); + +// Initial arrays... +var zx0 = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var zy0 = new Complex64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); + +// Create offset views... +var zx1 = new Complex64Array( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var zy1 = new Complex64Array( zy0.buffer, zy0.BYTES_PER_ELEMENT*2 ); // start at 3th element + +var z = cdotu( 1, zx1, 1, zy1, 1 ); +// returns + +var re = real( z ); +// returns -15.0 + +var im = imag( z ); +// returns 80.0 +``` + +#### cdotu.ndarray( N, zx, strideX, offsetX, zy, strideY, offsetY ) + +Calculates the dot product of `zx` and `zy` using alternative indexing semantics. + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); +var real = require( '@stdlib/complex/float32/real' ); +var imag = require( '@stdlib/complex/float32/imag' ); + +var zx = new Complex64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); +var zy = new Complex64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); + +var z = cdotu.ndarray( zx.length, zx, 1, 0, zy, 1, 0 ); +// returns + +var re = real( z ); +// returns -52.0 + +var im = imag( z ); +// returns 82.0 +``` + +The function has the following additional parameters: + +- **offsetX**: starting index for `zx`. +- **offsetY**: starting index for `zy`. + +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 calculate the dot product of every other value in `zx` starting from the second value with the last 2 elements in `zy` in reverse order + +```javascript +var Complex64Array = require( '@stdlib/array/complex64' ); +var real = require( '@stdlib/complex/float32/real' ); +var imag = require( '@stdlib/complex/float32/imag' ); + +var zx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var zy = new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); // eslint-disable-line max-len + +var z = cdotu.ndarray( 2, zx, 2, 1, zy, -1, zy.length-1 ); +// returns + +var re = real( z ); +// returns -40.0 + +var im = imag( z ); +// returns 310.0 +``` + +
+ + + +
+ +## Notes + +- If `N <= 0`, both functions return `0.0 + 0.0i`. +- `cdotu()` corresponds to the [BLAS][blas] level 1 function [`cdotu`][cdotu]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var cdotu = require( '@stdlib/blas/base/cdotu' ); + +function rand() { + return new Complex64( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +var zx = filledarrayBy( 10, 'complex64', rand ); +console.log( zx.toString() ); + +var zy = filledarrayBy( 10, 'complex64', rand ); +console.log( zy.toString() ); + +var out = cdotu.ndarray( zx.length, zx, 1, 0, zy, -1, zy.length-1 ); +console.log( out.toString() ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/cdotu/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/cdotu/benchmark/benchmark.js new file mode 100644 index 000000000000..9785d1663ddc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cdotu/benchmark/benchmark.js @@ -0,0 +1,107 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var pkg = require( './../package.json' ).name; +var cdotu = require( './../lib/cdotu.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var zx; + var zy; + + zx = new Complex64Array( uniform( len*2, -100.0, 100.0, options ) ); + zy = new Complex64Array( uniform( len*2, -100.0, 100.0, options ) ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = cdotu( zx.length, zx, 1, zy, 1 ); + if ( isnan( d ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( d ) ) { + 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 = 5; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/cdotu/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/cdotu/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..7be9e547890d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cdotu/benchmark/benchmark.ndarray.js @@ -0,0 +1,107 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Complex64Array = require( '@stdlib/array/complex128' ); +var pkg = require( './../package.json' ).name; +var cdotu = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var zx; + var zy; + + zx = new Complex64Array( uniform( len*2, -100.0, 100.0, options ) ); + zy = new Complex64Array( uniform( len*2, -100.0, 100.0, options ) ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = cdotu( zx.length, zx, 1, 0, zy, 1, 0 ); + if ( isnan( d ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( d ) ) { + 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 = 5; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':ndarray:len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/cdotu/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/cdotu/docs/types/index.d.ts new file mode 100644 index 000000000000..96de97a9230c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cdotu/docs/types/index.d.ts @@ -0,0 +1,140 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Complex64Array } from '@stdlib/types/array'; +import { Complex64 } from '@stdlib/types/complex'; + +/** +* Interface describing `cdotu`. +*/ +interface Routine { + /** + * Calculates the dot product of vectors `zx` and `zy`. + * + * @param N - number of indexed elements + * @param zx - first input array + * @param strideX - `zx` stride length + * @param zy - second input array + * @param strideY - `zy` stride length + * @returns dot product + * + * @example + * var Complex64Array = require( '@stdlib/array/complex64' ); + * var real = require( '@stdlib/complex/float32/real' ); + * var imag = require( '@stdlib/complex/float32/imag' ); + * + * var zx = new Complex64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); + * var zy = new Complex64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); + * + * var z = cdotu( 3, zx, 1, zy, 1 ); + * // returns + * + * var re = real( z ); + * // returns -52.0 + * + * var im = imag( z ); + * // returns 82.0 + */ + ( N: number, zx: Complex64Array, strideX: number, zy: Complex64Array, strideY: number ): Complex64; + + /** + * Calculates the dot product of vectors `zx` and `zy` using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param zx - first input array + * @param strideX - `zx` stride length + * @param offsetX - starting index for `zx` + * @param zy - second input array + * @param strideY - `zy` stride length + * @param offsetY - starting index for `zy` + * @returns dot product + * + * @example + * var Complex64Array = require( '@stdlib/array/complex64' ); + * var real = require( '@stdlib/complex/float32/real' ); + * var imag = require( '@stdlib/complex/float32/imag' ); + * + * var zx = new Complex64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); + * var zy = new Complex64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); + * + * var z = cdotu.ndarray( 3, zx, 1, 0, zy, 1, 0 ); + * // returns + * + * var re = real( z ); + * // returns -52.0 + * + * var im = imag( z ); + * // returns 82.0 + */ + ndarray( N: number, zx: Complex64Array, strideX: number, offsetX: number, zy: Complex64Array, strideY: number, offsetY: number ): Complex64; +} + +/** +* Computes the dot product of two single-precision complex floating-point vectors. +* +* @param N - number of indexed elements +* @param zx - first input array +* @param strideX - `zx` stride length +* @param zy - second input array +* @param strideY - `zy` stride length +* @returns dot product +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var real = require( '@stdlib/complex/float32/real' ); +* var imag = require( '@stdlib/complex/float32/imag' ); +* +* var zx = new Complex64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); +* var zy = new Complex64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); +* +* var z = cdotu( 3, zx, 1, zy, 1 ); +* // returns +* +* var re = real( z ); +* // returns -52.0 +* +* var im = imag( z ); +* // returns 82.0 +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var real = require( '@stdlib/complex/float32/real' ); +* var imag = require( '@stdlib/complex/float32/imag' ); +* +* var zx = new Complex64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); +* var zy = new Complex64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); +* +* var z = cdotu.ndarray( 3, zx, 1, 0, zy, 1, 0 ); +* // returns +* +* var re = real( z ); +* // returns -52.0 +* +* var im = imag( z ); +* // returns 82.0 +*/ +declare var cdotu: Routine; + + +// EXPORTS // + +export = cdotu; diff --git a/lib/node_modules/@stdlib/blas/base/cdotu/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/cdotu/docs/types/test.ts new file mode 100644 index 000000000000..d7f3fe0dda43 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cdotu/docs/types/test.ts @@ -0,0 +1,249 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import Complex64Array = require( '@stdlib/array/complex64' ); +import cdotu = require( './index' ); + + +// TESTS // + +// The function returns Complex64... +{ + const zx = new Complex64Array( 10 ); + const zy = new Complex64Array( 10 ); + + cdotu( zx.length, zx, 1, zy, 1 ); // $ExpectType Complex64 +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const zx = new Complex64Array( 10 ); + const zy = new Complex64Array( 10 ); + + cdotu( '10', zx, 1, zy, 1 ); // $ExpectError + cdotu( true, zx, 1, zy, 1 ); // $ExpectError + cdotu( false, zx, 1, zy, 1 ); // $ExpectError + cdotu( null, zx, 1, zy, 1 ); // $ExpectError + cdotu( undefined, zx, 1, zy, 1 ); // $ExpectError + cdotu( [], zx, 1, zy, 1 ); // $ExpectError + cdotu( {}, zx, 1, zy, 1 ); // $ExpectError + cdotu( ( zx: number ): number => zx, zx, 1, zy, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Complex64Array... +{ + const zx = new Complex64Array( 10 ); + const zy = new Complex64Array( 10 ); + + cdotu( zx.length, 10, 1, zy, 1 ); // $ExpectError + cdotu( zx.length, '10', 1, zy, 1 ); // $ExpectError + cdotu( zx.length, true, 1, zy, 1 ); // $ExpectError + cdotu( zx.length, false, 1, zy, 1 ); // $ExpectError + cdotu( zx.length, null, 1, zy, 1 ); // $ExpectError + cdotu( zx.length, undefined, 1, zy, 1 ); // $ExpectError + cdotu( zx.length, [ '1' ], 1, zy, 1 ); // $ExpectError + cdotu( zx.length, {}, 1, zy, 1 ); // $ExpectError + cdotu( zx.length, ( zx: number ): number => zx, 1, zy, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const zx = new Complex64Array( 10 ); + const zy = new Complex64Array( 10 ); + + cdotu( zx.length, zx, '10', zy, 1 ); // $ExpectError + cdotu( zx.length, zx, true, zy, 1 ); // $ExpectError + cdotu( zx.length, zx, false, zy, 1 ); // $ExpectError + cdotu( zx.length, zx, null, zy, 1 ); // $ExpectError + cdotu( zx.length, zx, undefined, zy, 1 ); // $ExpectError + cdotu( zx.length, zx, [], zy, 1 ); // $ExpectError + cdotu( zx.length, zx, {}, zy, 1 ); // $ExpectError + cdotu( zx.length, zx, ( zx: number ): number => zx, zy, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Complex64Array... +{ + const zx = new Complex64Array( 10 ); + + cdotu( zx.length, zx, 1, 10, 1 ); // $ExpectError + cdotu( zx.length, zx, 1, '10', 1 ); // $ExpectError + cdotu( zx.length, zx, 1, true, 1 ); // $ExpectError + cdotu( zx.length, zx, 1, false, 1 ); // $ExpectError + cdotu( zx.length, zx, 1, null, 1 ); // $ExpectError + cdotu( zx.length, zx, 1, undefined, 1 ); // $ExpectError + cdotu( zx.length, zx, 1, [], 1 ); // $ExpectError + cdotu( zx.length, zx, 1, {}, 1 ); // $ExpectError + cdotu( zx.length, zx, 1, ( zx: number ): number => zx, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const zx = new Complex64Array( 10 ); + const zy = new Complex64Array( 10 ); + + cdotu( zx.length, zx, 1, zy, '10' ); // $ExpectError + cdotu( zx.length, zx, 1, zy, true ); // $ExpectError + cdotu( zx.length, zx, 1, zy, false ); // $ExpectError + cdotu( zx.length, zx, 1, zy, null ); // $ExpectError + cdotu( zx.length, zx, 1, zy, undefined ); // $ExpectError + cdotu( zx.length, zx, 1, zy, [] ); // $ExpectError + cdotu( zx.length, zx, 1, zy, {} ); // $ExpectError + cdotu( zx.length, zx, 1, zy, ( zx: number ): number => zx ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const zx = new Complex64Array( 10 ); + const zy = new Complex64Array( 10 ); + + cdotu(); // $ExpectError + cdotu( zx.length ); // $ExpectError + cdotu( zx.length, zx ); // $ExpectError + cdotu( zx.length, zx, 1 ); // $ExpectError + cdotu( zx.length, zx, 1, zy ); // $ExpectError + cdotu( zx.length, zx, 1, zy, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Complex64... +{ + const zx = new Complex64Array( 10 ); + const zy = new Complex64Array( 10 ); + + cdotu.ndarray( zx.length, zx, 1, 0, zy, 1, 0 ); // $ExpectType Complex64 +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const zx = new Complex64Array( 10 ); + const zy = new Complex64Array( 10 ); + + cdotu.ndarray( '10', zx, 1, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( true, zx, 1, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( false, zx, 1, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( null, zx, 1, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( undefined, zx, 1, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( [], zx, 1, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( {}, zx, 1, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( ( zx: number ): number => zx, zx, 1, 0, zy, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a Complex64Array... +{ + const zx = new Complex64Array( 10 ); + const zy = new Complex64Array( 10 ); + + cdotu.ndarray( zx.length, 10, 1, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, '10', 1, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, true, 1, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, false, 1, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, null, 1, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, undefined, 1, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, [], 1, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, {}, 1, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, ( zx: number ): number => zx, 1, 0, zy, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const zx = new Complex64Array( 10 ); + const zy = new Complex64Array( 10 ); + + cdotu.ndarray( zx.length, zx, '10', 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, true, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, false, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, null, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, undefined, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, [], 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, {}, 0, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, ( zx: number ): number => zx, 0, zy, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const zx = new Complex64Array( 10 ); + const zy = new Complex64Array( 10 ); + + cdotu.ndarray( zx.length, zx, 1, '10', zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, true, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, false, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, null, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, undefined, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, [], zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, {}, zy, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, ( zx: number ): number => zx, zy, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a Complex64Array... +{ + const zx = new Complex64Array( 10 ); + + cdotu.ndarray( zx.length, zx, 1, 0, 10, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, '10', 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, true, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, false, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, null, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, undefined, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, [], 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, {}, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, ( zx: number ): number => zx, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... +{ + const zx = new Complex64Array( 10 ); + const zy = new Complex64Array( 10 ); + + cdotu.ndarray( zx.length, zx, 1, 0, zy, '10', 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy, true, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy, false, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy, null, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy, undefined, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy, [], 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy, {}, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy, ( zx: number ): number => zx, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... +{ + const zx = new Complex64Array( 10 ); + const zy = new Complex64Array( 10 ); + + cdotu.ndarray( zx.length, zx, 1, 0, zy, 1, '10' ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy, 1, true ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy, 1, false ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy, 1, null ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy, 1, undefined ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy, 1, [] ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy, 1, {} ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy, 1, ( zx: number ): number => zx ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const zx = new Complex64Array( 10 ); + const zy = new Complex64Array( 10 ); + + cdotu.ndarray(); // $ExpectError + cdotu.ndarray( zx.length ); // $ExpectError + cdotu.ndarray( zx.length, zx ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy, 1 ); // $ExpectError + cdotu.ndarray( zx.length, zx, 1, 0, zy, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/cdotu/examples/index.js b/lib/node_modules/@stdlib/blas/base/cdotu/examples/index.js new file mode 100644 index 000000000000..50eb26da8bce --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cdotu/examples/index.js @@ -0,0 +1,37 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var cdotu = require( '@stdlib/blas/base/cdotu' ); + +function rand() { + return new Complex64( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +var zx = filledarrayBy( 10, 'complex64', rand ); +console.log( zx.toString() ); + +var zy = filledarrayBy( 10, 'complex64', rand ); +console.log( zy.toString() ); + +var out = cdotu.ndarray( zx.length, zx, 1, 0, zy, -1, zy.length-1 ); +console.log( out.toString() ); diff --git a/lib/node_modules/@stdlib/blas/base/cdotu/lib/cdotu.js b/lib/node_modules/@stdlib/blas/base/cdotu/lib/cdotu.js new file mode 100644 index 000000000000..1d2da83f4938 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cdotu/lib/cdotu.js @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Calculates the dot product of two single-precision complex floating-point vectors. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex64Array} zx - first input array +* @param {integer} strideX - `zx` stride length +* @param {Complex64Array} zy - second input array +* @param {integer} strideY - `zy` stride length +* @returns {Complex64} dot product +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var real = require( '@stdlib/complex/float32/real' ); +* var imag = require( '@stdlib/complex/float32/imag' ); +* +* var zx = new Complex64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); +* var zy = new Complex64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); +* +* var z = cdotu( 3, zx, 1, zy, 1 ); +* // returns +* +* var re = real( z ); +* // returns -52.0 +* +* var im = imag( z ); +* // returns 82.0 +*/ +function cdotu( N, zx, strideX, zy, strideY ) { + var ix = stride2offset( N, strideX ); + var iy = stride2offset( N, strideY ); + return ndarray( N, zx, strideX, ix, zy, strideY, iy ); +} + + +// EXPORTS // + +module.exports = cdotu; diff --git a/lib/node_modules/@stdlib/blas/base/cdotu/lib/index.js b/lib/node_modules/@stdlib/blas/base/cdotu/lib/index.js new file mode 100644 index 000000000000..9a5444929a5a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cdotu/lib/index.js @@ -0,0 +1,86 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* BLAS level 1 routine to compute the dot product of two single-precision complex floating-point vectors. +* +* @module @stdlib/blas/base/cdotu +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var real = require( '@stdlib/complex/float32/real' ); +* var imag = require( '@stdlib/complex/float32/imag' ); +* var cdotu = require( '@stdlib/blas/base/cdotu' ); +* +* var zx = new Complex64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); +* var zy = new Complex64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); +* +* var z = cdotu( 3, zx, 1, zy, 1 ); +* // returns +* +* var re = real( z ); +* // returns -52.0 +* +* var im = imag( z ); +* // returns 82.0 +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var real = require( '@stdlib/complex/float32/real' ); +* var imag = require( '@stdlib/complex/float32/imag' ); +* var cdotu = require( '@stdlib/blas/base/cdotu' ); +* +* var zx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var zy = new Complex64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); +* +* var z = cdotu.ndarray( 2, zx, 2, 1, zy, -1, zy.length-1 ); +* // returns +* +* var re = real( z ); +* // returns -40.0 +* +* var im = imag( z ); +* // returns 310.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 cdotu; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + cdotu = main; +} else { + cdotu = tmp; +} + + +// EXPORTS // + +module.exports = cdotu; + +// exports: { "ndarray": "cdotu.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/cdotu/lib/main.js b/lib/node_modules/@stdlib/blas/base/cdotu/lib/main.js new file mode 100644 index 000000000000..e9627d52ef51 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cdotu/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var cdotu = require( './cdotu.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( cdotu, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = cdotu; diff --git a/lib/node_modules/@stdlib/blas/base/cdotu/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/cdotu/lib/ndarray.js new file mode 100644 index 000000000000..21e31c2a4398 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cdotu/lib/ndarray.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var cmul = require( '@stdlib/complex/float32/base/mul' ); +var cadd = require( '@stdlib/complex/float32/base/add' ); + + +// MAIN // + +/** +* Calculates the dot product of two single-precision complex floating-point vectors. +* +* @param {integer} N - number of indexed elements +* @param {Complex64Array} zx - first input array +* @param {integer} strideX - `zx` stride length +* @param {NonNegativeInteger} offsetX - starting index for `zx` +* @param {Complex64Array} zy - second input array +* @param {integer} strideY - `zy` stride length +* @param {NonNegativeInteger} offsetY - starting index for `zy` +* @returns {Complex64} dot product +* +* @example +* var Complex64Array = require( '@stdlib/array/complex64' ); +* var real = require( '@stdlib/complex/float32/real' ); +* var imag = require( '@stdlib/complex/float32/imag' ); +* +* var zx = new Complex64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); +* var zy = new Complex64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); +* +* var z = cdotu( 3, zx, 1, 0, zy, 1, 0 ); +* // returns +* +* var re = real( z ); +* // returns -52.0 +* +* var im = imag( z ); +* // returns 82.0 +*/ +function cdotu( N, zx, strideX, offsetX, zy, strideY, offsetY ) { + var dot; + var ix; + var iy; + var i; + + dot = new Complex64( 0.0, 0.0 ); + if ( N <= 0 ) { + return dot; + } + ix = offsetX; + iy = offsetY; + for ( i = 0; i < N; i++ ) { + dot = cadd( cmul( zx.get( ix ), zy.get( iy ) ), dot ); + ix += strideX; + iy += strideY; + } + return dot; +} + + +// EXPORTS // + +module.exports = cdotu; diff --git a/lib/node_modules/@stdlib/blas/base/cdotu/package.json b/lib/node_modules/@stdlib/blas/base/cdotu/package.json new file mode 100644 index 000000000000..128c67121984 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cdotu/package.json @@ -0,0 +1,82 @@ +{ + "name": "@stdlib/blas/base/cdotu", + "version": "0.0.0", + "description": "Calculate the dot product of two single-precision complex floating-point vectors.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "level 1", + "linear", + "algebra", + "subroutines", + "cdotu", + "dot", + "product", + "dot product", + "scalar", + "scalar product", + "inner", + "inner product", + "vector", + "typed", + "array", + "ndarray", + "complex", + "complex64", + "single", + "float32", + "float32array" + ], + "__stdlib__": { + "wasm": false + } +} diff --git a/lib/node_modules/@stdlib/blas/base/cdotu/test/test.cdotu.js b/lib/node_modules/@stdlib/blas/base/cdotu/test/test.cdotu.js new file mode 100644 index 000000000000..f6d9ffa68c9f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cdotu/test/test.cdotu.js @@ -0,0 +1,217 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var isSameComplex64 = require( '@stdlib/assert/is-same-complex64' ); +var cdotu = require( './../lib/cdotu.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof cdotu, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( cdotu.length, 5, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the dot product of two single-precision complex floating-point vectors `zx` and `zy`', function test( t ) { + var dot; + var zx; + var zy; + + zx = new Complex64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 2.0, -5.0, 6.0 ] ); + zy = new Complex64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 8.0, 2.0, -3.0 ] ); + + dot = cdotu( 4, zx, 1, zy, 1 ); + t.strictEqual( isSameComplex64( dot, new Complex64( 3, 70 ) ), true, 'returns expected value' ); + + zx = new Complex64Array( [ 3.0, -4.0, 1.0, 2.0 ] ); + zy = new Complex64Array( [ 1.0, -2.0, 3.0, 8.0 ] ); + + dot = cdotu( 2, zx, 1, zy, 1 ); + t.strictEqual( isSameComplex64( dot, new Complex64( -18, 4 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0 + 0i`', function test( t ) { + var dot; + var zx; + var zy; + + zx = new Complex64Array( [ 3.0, -4.0, 1.0, 7.0 ] ); + zy = new Complex64Array( [ 1.0, -2.0, 3.0, -3.0 ] ); + + dot = cdotu( 0, zx, 1, zy, 1 ); + t.strictEqual( isSameComplex64( dot, new Complex64( 0, 0 ) ), true, 'returns expected value' ); + + dot = cdotu( -4, zx, 1, zy, 1 ); + t.strictEqual( isSameComplex64( dot, new Complex64( 0, 0 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `zx` stride', function test( t ) { + var dot; + var zx; + var zy; + + zx = new Complex64Array([ + 2.0, // 0 + -3.0, // 0 + -5.0, + 6.0, + 7.0, // 1 + 6.0 // 1 + ]); + zy = new Complex64Array([ + 8.0, // 0 + 2.0, // 0 + -3.0, // 1 + 3.0, // 1 + -4.0, + 1.0 + ]); + + dot = cdotu( 2, zx, 2, zy, 1 ); + t.strictEqual( isSameComplex64( dot, new Complex64( -17, -17 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `zy` stride', function test( t ) { + var dot; + var zx; + var zy; + + zx = new Complex64Array([ + 2.0, // 0 + -3.0, // 0 + -5.0, // 1 + 7.0, // 1 + 6.0, + -2.0 + ]); + zy = new Complex64Array([ + 8.0, // 0 + 2.0, // 0 + -3.0, + 3.0, + -4.0, // 1 + 1.0 // 1 + ]); + + dot = cdotu( 2, zx, 1, zy, 2 ); + t.strictEqual( isSameComplex64( dot, new Complex64( 35, -53 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var dot; + var zx; + var zy; + + zx = new Complex64Array([ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 0 + 6.0 // 0 + ]); + zy = new Complex64Array([ + 7.0, // 1 + 8.0, // 1 + 9.0, // 0 + 10.0, // 0 + 11.0, + 12.0 + ]); + + dot = cdotu( 2, zx, -2, zy, -1 ); + t.strictEqual( isSameComplex64( dot, new Complex64( -24, 126 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var dot; + var zx; + var zy; + + zx = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0 // 1 + ]); + zy = new Complex64Array([ + 7.0, // 0 + 8.0, // 0 + 9.0, // 1 + 10.0, // 1 + 11.0, + 12.0 + ]); + + dot = cdotu( 2, zx, 2, zy, -1 ); + t.strictEqual( isSameComplex64( dot, new Complex64( -24, 110 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var dot; + var x0; + var y0; + var x1; + var y1; + + x0 = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0 // 1 + ]); + y0 = new Complex64Array([ + 7.0, + 8.0, + 9.0, // 0 + 10.0, // 0 + 11.0, // 1 + 12.0 // 1 + ]); + + x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*0 ); + y1 = new Complex64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); + + dot = cdotu( 2, x1, 2, y1, 1 ); + t.strictEqual( isSameComplex64( dot, new Complex64( -28, 154 ) ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/cdotu/test/test.js b/lib/node_modules/@stdlib/blas/base/cdotu/test/test.js new file mode 100644 index 000000000000..04a656870507 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cdotu/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var cdotu = 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 cdotu, '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 cdotu.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 cdotu = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( cdotu, mock, 'returns expected value' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var cdotu; + var main; + + main = require( './../lib/cdotu.js' ); + + cdotu = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( cdotu, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/cdotu/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/cdotu/test/test.ndarray.js new file mode 100644 index 000000000000..fc9c1891c75c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cdotu/test/test.ndarray.js @@ -0,0 +1,239 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var Complex64Array = require( '@stdlib/array/complex64' ); +var isSameComplex64 = require( '@stdlib/assert/is-same-complex64' ); +var cdotu = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof cdotu, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( cdotu.length, 7, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the dot product of two single-precision complex floating-point vectors `zx` and `zy`', function test( t ) { + var dot; + var zx; + var zy; + + zx = new Complex64Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 2.0, -5.0, 6.0 ] ); + zy = new Complex64Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 8.0, 2.0, -3.0 ] ); + + dot = cdotu( zx.length, zx, 1, 0, zy, 1, 0 ); + t.strictEqual(isSameComplex64( dot, new Complex64( 3, 70 ) ), true, 'returns expected value' ); + + zx = new Complex64Array( [ 3.0, -4.0, 1.0, 2.0 ] ); + zy = new Complex64Array( [ 1.0, -2.0, 3.0, 8.0 ] ); + + dot = cdotu( zx.length, zx, 1, 0, zy, 1, 0 ); + t.strictEqual( isSameComplex64( dot, new Complex64( -18, 4 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', function test( t ) { + var dot; + var zx; + var zy; + + zx = new Complex64Array( [ 3.0, -4.0, 1.0, 7.0 ] ); + zy = new Complex64Array( [ 1.0, -2.0, 3.0, -3.0 ] ); + + dot = cdotu( 0, zx, 1, 0, zy, 1, 0 ); + t.strictEqual( isSameComplex64( dot, new Complex64( 0, 0 ) ), true, 'returns expected value' ); + + dot = cdotu( -4, zx, 1, 0, zy, 1, 0 ); + t.strictEqual( isSameComplex64( dot, new Complex64( 0, 0 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `zx` stride', function test( t ) { + var dot; + var zx; + var zy; + + zx = new Complex64Array([ + 2.0, // 0 + -3.0, // 0 + -5.0, + 6.0, + 7.0, // 1 + 6.0 // 1 + ]); + zy = new Complex64Array([ + 8.0, // 0 + 2.0, // 0 + -3.0, // 1 + 3.0, // 1 + -4.0, + 1.0 + ]); + + dot = cdotu( 2, zx, 2, 0, zy, 1, 0 ); + t.strictEqual( isSameComplex64( dot, new Complex64( -17, -17 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `zx` offset', function test( t ) { + var dot; + var zx; + var zy; + + zx = new Complex64Array([ + 2.0, + -3.0, + -5.0, // 0 + 6.0, // 0 + 7.0, // 1 + 6.0 // 1 + ]); + zy = new Complex64Array([ + 8.0, // 0 + 2.0, // 0 + -3.0, // 1 + 3.0, // 1 + -4.0, + 1.0 + ]); + + dot = cdotu( 2, zx, 1, 1, zy, 1, 0 ); + t.strictEqual( isSameComplex64( dot, new Complex64( -91, 41 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `zy` stride', function test( t ) { + var dot; + var zx; + var zy; + + zx = new Complex64Array([ + 2.0, // 0 + -3.0, // 0 + -5.0, // 1 + 6.0, // 1 + 7.0, + 6.0 + ]); + zy = new Complex64Array([ + 8.0, // 0 + 2.0, // 0 + -3.0, + 3.0, + -4.0, // 1 + 1.0 // 1 + ]); + + dot = cdotu( 2, zx, 1, 0, zy, 2, 0 ); + t.strictEqual( isSameComplex64( dot, new Complex64( 36, -49 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `zy` offset', function test( t ) { + var dot; + var zx; + var zy; + + zx = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0 // 1 + ]); + zy = new Complex64Array([ + 7.0, + 8.0, + 9.0, // 0 + 10.0, // 0 + 11.0, // 1 + 12.0 // 1 + ]); + + dot = cdotu( 2, zx, 2, 0, zy, 1, 1 ); + t.strictEqual( isSameComplex64( dot, new Complex64( -28, 154 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var dot; + var zx; + var zy; + + zx = new Complex64Array([ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 0 + 6.0 // 0 + ]); + zy = new Complex64Array([ + 7.0, + 8.0, + 9.0, // 1 + 10.0, // 1 + 11.0, // 0 + 12.0 // 0 + ]); + + dot = cdotu( 2, zx, -2, zx.length-1, zy, -1, 2 ); + t.strictEqual( isSameComplex64( dot, new Complex64( -28, 154 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var dot; + var zx; + var zy; + + zx = new Complex64Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0 // 1 + ]); + zy = new Complex64Array([ + 7.0, // 0 + 8.0, // 0 + 9.0, // 1 + 10.0, // 1 + 11.0, + 12.0 + ]); + + dot = cdotu( 2, zx, 2, 0, zy, -1, zy.length-2 ); + t.strictEqual( isSameComplex64( dot, new Complex64( -24, 110 ) ), true, 'returns expected value' ); + t.end(); +}); From 1fbde8e370bd2a448835d98f4eb3f33d46ff33b8 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Thu, 16 Jan 2025 09:30:33 +0000 Subject: [PATCH 2/2] add repl file --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../@stdlib/blas/base/cdotu/docs/repl.txt | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/cdotu/docs/repl.txt diff --git a/lib/node_modules/@stdlib/blas/base/cdotu/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/cdotu/docs/repl.txt new file mode 100644 index 000000000000..944e59ca693e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/cdotu/docs/repl.txt @@ -0,0 +1,124 @@ + +{{alias}}( N, zx, strideX, zy, strideY ) + Calculate the dot product of two single-precision complex floating-point + vectors. + + The `N` and stride parameters determine which elements in the strided + arrays are accessed at runtime. + + Indexing is relative to the first index. To introduce an offset, use a + typed array view. + + If `N <= 0`, the function returns `0 + 0i`. + + Parameters + ---------- + N: integer + Number of indexed elements. + + zx: Complex64Array + First input array. + + strideX: integer + Index increment for `zx`. + + zy: Complex64Array + Second input array. + + strideY: integer + Index increment for `zy`. + + Returns + ------- + out: Complex64 + Scalar constant. + + Examples + -------- + // Standard usage: + > var zx = new {{alias:@stdlib/array/complex64}}( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); + > var zy = new {{alias:@stdlib/array/complex64}}( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); + > var z = {{alias}}( 3, zx, 1, zy, 1 ); + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + -52.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + 82.0 + + // Advanced indexing: + > var zx = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var zy = new {{alias:@stdlib/array/complex64}}( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + > var z = {{alias}}( 2, zx, 2, zy, -1 ); + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + -2.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + 14.0 + + // Using typed array views: + > var zx0 = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var zy0 = new {{alias:@stdlib/array/complex64}}( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); + > var zx1 = new {{alias:@stdlib/array/complex64}}( zx0.buffer, zx0.BYTES_PER_ELEMENT*1 ); + > var zy1 = new {{alias:@stdlib/array/complex64}}( zy0.buffer, zy0.BYTES_PER_ELEMENT*2 ); + > var z = {{alias}}( 1, zx1, 1, zy1, 1 ); + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + -15.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + 80.0 + + +{{alias}}.ndarray( N, zx, strideX, offsetX, zy, strideY, offsetY ) + Computes the dot product of two single-precision complex floating-point + vectors using alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing based on a starting index. + + Parameters + ---------- + N: integer + Number of indexed elements. + + zx: Complex64Array + First input array. + + strideX: integer + Index increment for `zx`. + + offsetX: integer + Starting index for `zx`. + + zy: Complex64Array + Second input array. + + strideY: integer + Index increment for `zy`. + + offsetY: integer + Starting index for `zy`. + + Returns + ------- + out: Complex64 + Second input array. + + Examples + -------- + // Standard usage: + > var zx = new {{alias:@stdlib/array/complex64}}( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); + > var zy = new {{alias:@stdlib/array/complex64}}( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); + > var z = {{alias}}.ndarray( zx.length, zx, 1, 0, zy, 1, 0 ); + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + -52.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + 82.0 + + // Advanced indexing: + > var zx = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + > var zy = new {{alias:@stdlib/array/complex64}}( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + > var z = {{alias}}.ndarray( 2, zx, 2, 1, zy, -1, zy.length-1 ); + > var re = {{alias:@stdlib/complex/float32/real}}( z ) + -40.0 + > var im = {{alias:@stdlib/complex/float32/imag}}( z ) + 310.0 + + See Also + --------