diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/README.md b/lib/node_modules/@stdlib/blas/base/zdotu/README.md new file mode 100644 index 000000000000..8595d58e67e7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/README.md @@ -0,0 +1,362 @@ + + +# zdotu + +> Calculate the dot product of two single-precision complex floating-point vectors. + +
+ +The [dot product][dot-product] (or scalar product) is defined as + + + +```math +\mathbf{x}\cdot\mathbf{y} = \sum_{i=0}^{N-1} x_i y_i = x_0 y_0 + x_1 y_1 + \ldots + x_{N-1} y_{N-1} +``` + + + + + +
+ + + +
+ +## Usage + +```javascript +var zdotu = require( '@stdlib/blas/base/zdotu' ); +``` + +#### zdotu( N, x, strideX, y, strideY ) + +Calculates the dot product of vectors `x` and `y`. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var x = new Complex128Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); +var y = new Complex128Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); + +var z = zdotu( 3, x, 1, y, 1 ); +// returns [ -52.0, 82.0 ] +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **x**: input [`Complex128Array`][@stdlib/array/complex128]. +- **strideX**: stride length for `x`. +- **y**: input [`Complex128Array`][@stdlib/array/complex128]. +- **strideY**: stride length for `y`. + +The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to calculate the dot product of every other element in `x` and the first `N` elements of `y` in reverse order, + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var y = new Complex128Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + +var z = zdotu( 2, x, 2, y, -1 ); +// returns [ -2.0, 14.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( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var y0 = new Complex128Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.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*2 ); // start at 3rd element + +var z = zdotu( 1, x1, 1, y1, 1 ); +// returns [ -15.0, 80.0 ] +``` + +#### zdotu.ndarray( N, x, strideX, offsetX, y, strideY, offsetY ) + +Calculates the dot product of `x` and `y` using alternative indexing semantics. + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var x = new Complex128Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); +var y = new Complex128Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); + +var z = zdotu.ndarray( x.length, x, 1, 0, y, 1, 0 ); +// returns [ -52.0, 82.0 ] +``` + +The function has the following additional parameters: + +- **offsetX**: starting index for `x`. +- **offsetY**: starting index for `y`. + +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 element in `x` starting from the second element with the last 2 elements in `y` in reverse order + + + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); + +var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +var y = new Complex128Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); + +var z = zdotu.ndarray( 2, x, 2, 1, y, -1, y.length-1 ); +// returns [ -40.0, 310.0 ] +``` + +
+ + + +
+ +## Notes + +- If `N <= 0`, both functions return `0.0 + 0.0i`. +- `zdotu()` corresponds to the [BLAS][blas] level 1 function [`zdotu`][zdotu]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var zdotu = require( '@stdlib/blas/base/zdotu' ); + +function rand() { + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +var x = filledarrayBy( 10, 'complex128', rand ); +console.log( x.toString() ); + +var y = filledarrayBy( 10, 'complex128', rand ); +console.log( y.toString() ); + +// Compute the dot product: +var out = zdotu( x.length, x, 1, y, -1 ); +console.log( out.toString() ); + +// Compute the dot product using alternative indexing semantics: +out = zdotu.ndarray( x.length, x, 1, 0, y, -1, y.length-1 ); +console.log( out.toString() ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/zdotu.h" +``` + +#### c_zdotu( N, \*X, strideX, \*Y, strideY, \*dot ) + +Calculates the dot product of two single-precision complex floating-point vectors. + +```c +#include "stdlib/complex/float64/ctor.h" + +const double x[] = { 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 }; +const double y[] = { 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 }; + +stdlib_complex128_t dot; +c_zdotu( 3, (void *)x, 1, (void *)y, 1, (void *)&dot ); +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **X**: `[in] void*` first input array. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **Y**: `[in] void*` second input array. +- **strideY**: `[in] CBLAS_INT` index increment for `Y`. +- **dot**: `[out] void*` output variable. + +```c +void c_zdotu( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const void *Y, const CBLAS_INT strideY, void *dot ); +``` + +#### c_zdotu_ndarray( N, \*X, strideX, offsetX, \*Y, strideY, offsetY, \*dot ) + +Calculates the dot product of two single-precision complex floating-point vectors using alternative indexing semantics. + +```c +#include "stdlib/complex/float64/ctor.h" + +const double x[] = { 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 }; +const double y[] = { 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 }; + +stdlib_complex128_t dot; +c_zdotu_ndarray( 3, (void *)x, 1, 0, (void *)y, 1, 0, (void *)&dot ); +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **X**: `[in] void*` first input array. +- **strideX**: `[in] CBLAS_INT` index increment for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. +- **Y**: `[in] void*` second input array. +- **strideY**: `[in] CBLAS_INT` index increment for `Y`. +- **offsetY**: `[in] CBLAS_INT` starting index for `Y`. +- **dot**: `[out] void*` output variable. + +```c +void c_zdotu_ndarray( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const void *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, void *dot ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/base/zdotu.h" +#include "stdlib/complex/float64/real.h" +#include "stdlib/complex/float64/imag.h" +#include "stdlib/complex/float64/ctor.h" +#include + +int main( void ) { + // Create strided arrays: + const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + const double y[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; + + // Specify the number of elements: + const int N = 4; + + // Specify strides: + const int strideX = 1; + const int strideY = 1; + + // Create a complex number to store the result: + stdlib_complex128_t z; + + // Compute the dot product: + c_zdotu( N, (const void *)x, strideX, (const void *)y, strideY, (void *)&z ); + + // Print the result: + printf( "dot: %lf + %lfi\n", stdlib_complex128_real( z ), stdlib_complex128_imag( z ) ); + + // Compute the dot product: + c_zdotu_ndarray( N, (const void *)x, strideX, 0, (const void *)y, strideY, 0, (void *)&z ); + + // Print the result: + printf( "dot: %lf + %lfi\n", stdlib_complex128_real( z ), stdlib_complex128_imag( z ) ); +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/zdotu/benchmark/benchmark.js new file mode 100644 index 000000000000..42b29ff5c249 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/benchmark/benchmark.js @@ -0,0 +1,110 @@ +/** +* @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 real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var zdotu = require( './../lib/zdotu.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x; + var y; + + x = new Complex128Array( uniform( N*2, -100.0, 100.0, options ) ); + y = new Complex128Array( uniform( N*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 = zdotu( x.length, x, 1, y, 1 ); + if ( isnan( real( d ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( imag( d ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 5; // 10^max + + for ( i = min; i <= max; i++ ) { + N = pow( 10, i ); + f = createBenchmark( N ); + bench( format( '%s:len=%d', pkg, N ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/base/zdotu/benchmark/benchmark.native.js new file mode 100644 index 000000000000..4ae8d1aa217e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/benchmark/benchmark.native.js @@ -0,0 +1,115 @@ +/** +* @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 tryRequire = require( '@stdlib/utils/try-require' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var zdotu = tryRequire( resolve( __dirname, './../lib/zdotu.native.js' ) ); +var opts = { + 'skip': ( zdotu instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x; + var y; + + x = new Complex128Array( uniform( N*2, -100.0, 100.0, options ) ); + y = new Complex128Array( uniform( N*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 = zdotu( x.length, x, 1, y, 1 ); + if ( isnan( real( d ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( imag( d ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 5; // 10^max + + for ( i = min; i <= max; i++ ) { + N = pow( 10, i ); + f = createBenchmark( N ); + bench( format( '%s::native:len=%d', pkg, N ), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/zdotu/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..3bbc4901b491 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/benchmark/benchmark.ndarray.js @@ -0,0 +1,110 @@ +/** +* @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 real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var zdotu = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x; + var y; + + x = new Complex128Array( uniform( N*2, -100.0, 100.0, options ) ); + y = new Complex128Array( uniform( N*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 = zdotu( x.length, x, 1, 0, y, 1, 0 ); + if ( isnan( real( d ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( imag( d ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 5; // 10^max + + for ( i = min; i <= max; i++ ) { + N = pow( 10, i ); + f = createBenchmark( N ); + bench( format( '%s:ndarray:len=%d', pkg, N ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zdotu/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..3eddab5f12f8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,115 @@ +/** +* @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 tryRequire = require( '@stdlib/utils/try-require' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var zdotu = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( zdotu instanceof Error ) +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x; + var y; + + x = new Complex128Array( uniform( N*2, -100.0, 100.0, options ) ); + y = new Complex128Array( uniform( N*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 = zdotu( x.length, x, 1, 0, y, 1, 0 ); + if ( isnan( real( d ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( imag( d ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 5; // 10^max + + for ( i = min; i <= max; i++ ) { + N = pow( 10, i ); + f = createBenchmark( N ); + bench( format( '%s::native:ndarray:len=%d', pkg, N ), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/binding.gyp b/lib/node_modules/@stdlib/blas/base/zdotu/binding.gyp new file mode 100644 index 000000000000..60dce9d0b31a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/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/base/zdotu/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/zdotu/docs/repl.txt new file mode 100644 index 000000000000..f1d32a17c7e5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/docs/repl.txt @@ -0,0 +1,109 @@ + +{{alias}}( N, x, strideX, y, strideY ) + Computes 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`. + + Parameters + ---------- + N: integer + Number of indexed elements. + + x: Complex128Array + First input array. + + strideX: integer + Stride length for `x`. + + y: Complex128Array + Second input array. + + strideY: integer + Stride length for `y`. + + Returns + ------- + out: Complex128 + Dot product. + + Examples + -------- + // Standard usage: + > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var y = new {{alias:@stdlib/array/complex128}}( [ 6.0, 7.0, 8.0, 9.0 ] ); + > var z = {{alias}}( x.length, x, 1, y, 1 ) + [ -20.0, 78.0 ] + + // Advanced indexing: + > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var y = new {{alias:@stdlib/array/complex128}}( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + > var z = {{alias}}( 2, x, 2, y, -1 ) + [ -2.0, 14.0 ] + + // Using typed array views: + > var x0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var y0 = new {{alias:@stdlib/array/complex128}}( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); + > var x1 = new {{alias:@stdlib/array/complex128}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var y1 = new {{alias:@stdlib/array/complex128}}( y0.buffer, y0.BYTES_PER_ELEMENT*2 ); + > var z = {{alias}}( 1, x1, 1, y1, 1 ) + [ -15.0, 80.0 ] + + +{{alias}}.ndarray( N, x, strideX, offsetX, y, 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, offset parameters support indexing based on starting indices. + + Parameters + ---------- + N: integer + Number of indexed elements. + + x: Complex128Array + First input array. + + strideX: integer + Stride length for `x`. + + offsetX: integer + Starting index for `x`. + + y: Complex128Array + Second input array. + + strideY: integer + Stride length for `y`. + + offsetY: integer + Starting index for `y`. + + Returns + ------- + out: Complex128 + Dot product. + + Examples + -------- + // Standard usage: + > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var y = new {{alias:@stdlib/array/complex128}}( [ 6.0, 7.0, 8.0, 9.0 ] ); + > var z = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 ) + [ -20.0, 78.0 ] + + // Advanced indexing: + > var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var y = new {{alias:@stdlib/array/complex128}}( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + > var z = {{alias}}.ndarray( 1, x, 2, 1, y, -1, y.length-1 ) + [ -1.0, 7.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/zdotu/docs/types/index.d.ts new file mode 100644 index 000000000000..0ba5ea291ed8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/docs/types/index.d.ts @@ -0,0 +1,108 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Complex128Array } from '@stdlib/types/array'; +import { Complex128 } from '@stdlib/types/complex'; + +/** +* Interface describing `zdotu`. +*/ +interface Routine { + /** + * Calculates the dot product of vectors `x` and `y`. + * + * @param N - number of indexed elements + * @param x - first input array + * @param strideX - `x` stride length + * @param y - second input array + * @param strideY - `y` stride length + * @returns dot product + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * + * var x = new Complex128Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); + * var y = new Complex128Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); + * + * var z = zdotu( 3, x, 1, y, 1 ); + * // returns [ -52.0, 82.0 ] + */ + ( N: number, x: Complex128Array, strideX: number, y: Complex128Array, strideY: number ): Complex128; + + /** + * Computes the dot product of vectors `x` and `y` using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param x - first input array + * @param strideX - `x` stride length + * @param offsetX - starting index for `x` + * @param y - second input array + * @param strideY - `y` stride length + * @param offsetY - starting index for `y` + * @returns dot product + * + * @example + * var Complex128Array = require( '@stdlib/array/complex128' ); + * + * var x = new Complex128Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); + * var y = new Complex128Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); + * + * var z = zdotu.ndarray( x.length, x, 1, 0, y, 1, 0 ); + * // returns [ -52.0, 82.0 ] + */ + ndarray( N: number, x: Complex128Array, strideX: number, offsetX: number, y: Complex128Array, strideY: number, offsetY: number ): Complex128; +} + +/** +* Calculates the dot product of two single-precision complex floating-point vectors. +* +* @param N - number of indexed elements +* @param x - first input array +* @param strideX - `x` stride length +* @param y - second input array +* @param strideY - `y` stride length +* @returns dot product +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); +* var y = new Complex128Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); +* +* var z = zdotu( 3, x, 1, y, 1 ); +* // returns [ -52.0, 82.0 ] +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); +* var y = new Complex128Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); +* +* var z = zdotu.ndarray( x.length, x, 1, 0, y, 1, 0 ); +* // returns [ -52.0, 82.0 ] +*/ +declare var zdotu: Routine; + + +// EXPORTS // + +export = zdotu; diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/zdotu/docs/types/test.ts new file mode 100644 index 000000000000..cfb7f6e49537 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/docs/types/test.ts @@ -0,0 +1,249 @@ +/* +* @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 zdotu = require( './index' ); + + +// TESTS // + +// The function returns a complex number... +{ + const x = new Complex128Array( 10 ); + const y = new Complex128Array( 10 ); + + zdotu( x.length, x, 1, y, 1 ); // $ExpectType Complex128 +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const x = new Complex128Array( 10 ); + const y = new Complex128Array( 10 ); + + zdotu( '10', x, 1, y, 1 ); // $ExpectError + zdotu( true, x, 1, y, 1 ); // $ExpectError + zdotu( false, x, 1, y, 1 ); // $ExpectError + zdotu( null, x, 1, y, 1 ); // $ExpectError + zdotu( undefined, x, 1, y, 1 ); // $ExpectError + zdotu( [], x, 1, y, 1 ); // $ExpectError + zdotu( {}, x, 1, y, 1 ); // $ExpectError + zdotu( ( x: number ): number => x, x, 1, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Complex128Array... +{ + const x = new Complex128Array( 10 ); + const y = new Complex128Array( 10 ); + + zdotu( x.length, 10, 1, y, 1 ); // $ExpectError + zdotu( x.length, '10', 1, y, 1 ); // $ExpectError + zdotu( x.length, true, 1, y, 1 ); // $ExpectError + zdotu( x.length, false, 1, y, 1 ); // $ExpectError + zdotu( x.length, null, 1, y, 1 ); // $ExpectError + zdotu( x.length, undefined, 1, y, 1 ); // $ExpectError + zdotu( x.length, [ '1' ], 1, y, 1 ); // $ExpectError + zdotu( x.length, {}, 1, y, 1 ); // $ExpectError + zdotu( x.length, ( x: number ): number => x, 1, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Complex128Array( 10 ); + const y = new Complex128Array( 10 ); + + zdotu( x.length, x, '10', y, 1 ); // $ExpectError + zdotu( x.length, x, true, y, 1 ); // $ExpectError + zdotu( x.length, x, false, y, 1 ); // $ExpectError + zdotu( x.length, x, null, y, 1 ); // $ExpectError + zdotu( x.length, x, undefined, y, 1 ); // $ExpectError + zdotu( x.length, x, [], y, 1 ); // $ExpectError + zdotu( x.length, x, {}, y, 1 ); // $ExpectError + zdotu( x.length, x, ( x: number ): number => x, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Complex128Array... +{ + const x = new Complex128Array( 10 ); + + zdotu( x.length, x, 1, 10, 1 ); // $ExpectError + zdotu( x.length, x, 1, '10', 1 ); // $ExpectError + zdotu( x.length, x, 1, true, 1 ); // $ExpectError + zdotu( x.length, x, 1, false, 1 ); // $ExpectError + zdotu( x.length, x, 1, null, 1 ); // $ExpectError + zdotu( x.length, x, 1, undefined, 1 ); // $ExpectError + zdotu( x.length, x, 1, [], 1 ); // $ExpectError + zdotu( x.length, x, 1, {}, 1 ); // $ExpectError + zdotu( x.length, x, 1, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const x = new Complex128Array( 10 ); + const y = new Complex128Array( 10 ); + + zdotu( x.length, x, 1, y, '10' ); // $ExpectError + zdotu( x.length, x, 1, y, true ); // $ExpectError + zdotu( x.length, x, 1, y, false ); // $ExpectError + zdotu( x.length, x, 1, y, null ); // $ExpectError + zdotu( x.length, x, 1, y, undefined ); // $ExpectError + zdotu( x.length, x, 1, y, [] ); // $ExpectError + zdotu( x.length, x, 1, y, {} ); // $ExpectError + zdotu( x.length, x, 1, y, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Complex128Array( 10 ); + const y = new Complex128Array( 10 ); + + zdotu(); // $ExpectError + zdotu( x.length ); // $ExpectError + zdotu( x.length, x ); // $ExpectError + zdotu( x.length, x, 1 ); // $ExpectError + zdotu( x.length, x, 1, y ); // $ExpectError + zdotu( x.length, x, 1, y, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a complex number... +{ + const x = new Complex128Array( 10 ); + const y = new Complex128Array( 10 ); + + zdotu.ndarray( x.length, x, 1, 0, y, 1, 0 ); // $ExpectType Complex128 +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = new Complex128Array( 10 ); + const y = new Complex128Array( 10 ); + + zdotu.ndarray( '10', x, 1, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( true, x, 1, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( false, x, 1, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( null, x, 1, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( undefined, x, 1, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( [], x, 1, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( {}, x, 1, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( ( x: number ): number => x, x, 1, 0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a Complex128Array... +{ + const x = new Complex128Array( 10 ); + const y = new Complex128Array( 10 ); + + zdotu.ndarray( x.length, 10, 1, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, '10', 1, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, true, 1, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, false, 1, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, null, 1, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, undefined, 1, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, [], 1, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, {}, 1, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, ( x: number ): number => x, 1, 0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const x = new Complex128Array( 10 ); + const y = new Complex128Array( 10 ); + + zdotu.ndarray( x.length, x, '10', 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, true, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, false, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, null, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, undefined, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, [], 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, {}, 0, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, ( x: number ): number => x, 0, y, 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( 10 ); + const y = new Complex128Array( 10 ); + + zdotu.ndarray( x.length, x, 1, '10', y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, true, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, false, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, null, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, undefined, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, [], y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, {}, y, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, ( x: number ): number => x, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a Complex128Array... +{ + const x = new Complex128Array( 10 ); + + zdotu.ndarray( x.length, x, 1, 0, 10, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, '10', 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, true, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, false, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, null, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, undefined, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, [], 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, {}, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... +{ + const x = new Complex128Array( 10 ); + const y = new Complex128Array( 10 ); + + zdotu.ndarray( x.length, x, 1, 0, y, '10', 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y, true, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y, false, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y, null, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y, undefined, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y, [], 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y, {}, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y, ( x: number ): number => x, 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( 10 ); + const y = new Complex128Array( 10 ); + + zdotu.ndarray( x.length, x, 1, 0, y, 1, '10' ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y, 1, true ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y, 1, false ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y, 1, null ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y, 1, undefined ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y, 1, [] ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y, 1, {} ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y, 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( 10 ); + const y = new Complex128Array( 10 ); + + zdotu.ndarray(); // $ExpectError + zdotu.ndarray( x.length ); // $ExpectError + zdotu.ndarray( x.length, x ); // $ExpectError + zdotu.ndarray( x.length, x, 1 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y, 1 ); // $ExpectError + zdotu.ndarray( x.length, x, 1, 0, y, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/examples/c/Makefile b/lib/node_modules/@stdlib/blas/base/zdotu/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/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/base/zdotu/examples/c/example.c b/lib/node_modules/@stdlib/blas/base/zdotu/examples/c/example.c new file mode 100644 index 000000000000..01c2f11fb4e0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/examples/c/example.c @@ -0,0 +1,51 @@ +/** +* @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/base/zdotu.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/real.h" +#include "stdlib/complex/float64/imag.h" +#include + +int main( void ) { + // Create strided arrays: + const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 }; + const double y[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; + + // Specify the number of elements: + const int N = 4; + + // Specify strides: + const int strideX = 1; + const int strideY = 1; + + // Create a complex number to store the result: + stdlib_complex128_t z; + + // Compute the dot product: + c_zdotu( N, (const void *)x, strideX, (const void *)y, strideY, (void *)&z ); + + // Print the result: + printf( "dot: %lf + %lfi\n", stdlib_complex128_real( z ), stdlib_complex128_imag( z ) ); + + // Compute the dot product: + c_zdotu_ndarray( N, (const void *)x, strideX, 0, (const void *)y, strideY, 0, (void *)&z ); + + // Print the result: + printf( "dot: %lf + %lfi\n", stdlib_complex128_real( z ), stdlib_complex128_imag( z ) ); +} diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/examples/index.js b/lib/node_modules/@stdlib/blas/base/zdotu/examples/index.js new file mode 100644 index 000000000000..2ef89a82c2f0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/examples/index.js @@ -0,0 +1,42 @@ +/** +* @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 discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); +var zdotu = require( './../lib' ); + +function rand() { + return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) ); +} + +var x = filledarrayBy( 10, 'complex128', rand ); +console.log( x.toString() ); + +var y = filledarrayBy( 10, 'complex128', rand ); +console.log( y.toString() ); + +// Compute the dot product: +var out = zdotu( x.length, x, 1, y, -1 ); +console.log( out.toString() ); + +// Compute the dot product using alternative indexing semantics: +out = zdotu.ndarray( x.length, x, 1, 0, y, -1, y.length-1 ); +console.log( out.toString() ); diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/include.gypi b/lib/node_modules/@stdlib/blas/base/zdotu/include.gypi new file mode 100644 index 000000000000..dcb556d250e8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/include.gypi @@ -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. + +# A GYP include file for building a Node.js native add-on. +# +# Note that nesting variables is required due to how GYP processes a configuration. Any variables defined within a nested 'variables' section is defined in the outer scope. Thus, conditions in the outer variable scope are free to use these variables without running into "variable undefined" errors. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +# +# Variable nesting hacks: +# +# [3]: https://chromium.googlesource.com/external/skia/gyp/+/master/common_variables.gypi +# [4]: https://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?revision=127004 +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + 'variables': { + # Host BLAS library (to override -Dblas=): + 'blas%': '', + + # Path to BLAS library (to override -Dblas_dir=): + 'blas_dir%': '', + }, # end variables + + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '<@(blas_dir)', + '[ -52.0, 82.0 ] +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* var zdotu = require( '@stdlib/blas/base/zdotu' ); +* +* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +* var y = new Complex128Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); +* +* var z = zdotu.ndarray( 2, x, 2, 1, y, -1, y.length-1 ); +* // returns [ -40.0, 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 zdotu; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + zdotu = main; +} else { + zdotu = tmp; +} + + +// EXPORTS // + +module.exports = zdotu; + +// exports: { "ndarray": "zdotu.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/lib/main.js b/lib/node_modules/@stdlib/blas/base/zdotu/lib/main.js new file mode 100644 index 000000000000..392effd31cd5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/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 zdotu = require( './zdotu.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( zdotu, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = zdotu; diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/lib/native.js b/lib/node_modules/@stdlib/blas/base/zdotu/lib/native.js new file mode 100644 index 000000000000..a5ff2b0724b1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/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 zdotu = require( './zdotu.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( zdotu, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = zdotu; diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/zdotu/lib/ndarray.js new file mode 100644 index 000000000000..3a35e6007b21 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/lib/ndarray.js @@ -0,0 +1,88 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); + + +// MAIN // + +/** +* Calculates the dot product of two double-precision complex floating-point vectors. +* +* @param {integer} N - number of indexed elements +* @param {Complex128Array} x - first input array +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Complex128Array} y - second input array +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @returns {Complex128} dot product +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); +* var y = new Complex128Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); +* +* var z = zdotu( 3, x, 1, 0, y, 1, 0 ); +* // returns [ -52.0, 82.0 ] +*/ +function zdotu( N, x, strideX, offsetX, y, strideY, offsetY ) { + var viewX; + var viewY; + var tr; + var ti; + var ix; + var iy; + var sx; + var sy; + var i; + + if ( N <= 0 ) { + return new Complex128( 0.0, 0.0 ); + } + viewX = reinterpret( x, 0 ); + viewY = reinterpret( y, 0 ); + + ix = offsetX * 2; + iy = offsetY * 2; + sx = strideX * 2; + sy = strideY * 2; + + tr = 0.0; + ti = 0.0; + for ( i = 0; i < N; i++ ) { + tr += ( viewX[ ix ] * viewY[ iy ] ) - + ( viewX[ ix + 1 ] * viewY[ iy + 1 ] ); + ti += ( viewX[ ix ] * viewY[ iy + 1 ] ) + + ( viewX[ ix + 1 ] * viewY[ iy ] ); + ix += sx; + iy += sy; + } + return new Complex128( tr, ti ); +} + + +// EXPORTS // + +module.exports = zdotu; diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zdotu/lib/ndarray.native.js new file mode 100644 index 000000000000..ce3cf911c6cd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/lib/ndarray.native.js @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Calculates the dot product of two double-precision complex floating-point vectors. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex128Array} x - first input array +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Complex128Array} y - second input array +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @returns {Complex128} dot product +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); +* var y = new Complex128Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); +* +* var z = zdotu( 3, x, 1, 0, y, 1, 0 ); +* // returns [ -52.0, 82.0 ] +*/ +function zdotu( N, x, strideX, offsetX, y, strideY, offsetY ) { + var obj; + var vX; + var vY; + + vX = reinterpret( x, 0 ); + vY = reinterpret( y, 0 ); + obj = addon.ndarray( N, vX, strideX, offsetX, vY, strideY, offsetY ); + return new Complex128( obj.re, obj.im ); +} + + +// EXPORTS // + +module.exports = zdotu; diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/lib/zdotu.js b/lib/node_modules/@stdlib/blas/base/zdotu/lib/zdotu.js new file mode 100644 index 000000000000..ab311fc5f53e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/lib/zdotu.js @@ -0,0 +1,57 @@ +/** +* @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 stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Computes the dot product of two double-precision complex floating-point vectors. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex128Array} x - first input array +* @param {integer} strideX - `x` stride length +* @param {Complex128Array} y - second input array +* @param {integer} strideY - `y` stride length +* @returns {Complex128} dot product +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); +* var y = new Complex128Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); +* +* var z = zdotu( 3, x, 1, y, 1 ); +* // returns [ -52.0, 82.0 ] +*/ +function zdotu( N, x, strideX, y, strideY ) { + var ix = stride2offset( N, strideX ); + var iy = stride2offset( N, strideY ); + return ndarray( N, x, strideX, ix, y, strideY, iy ); +} + + +// EXPORTS // + +module.exports = zdotu; diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/lib/zdotu.native.js b/lib/node_modules/@stdlib/blas/base/zdotu/lib/zdotu.native.js new file mode 100644 index 000000000000..2395a8fd4084 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/lib/zdotu.native.js @@ -0,0 +1,59 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Calculates the dot product of two double-precision complex floating-point vectors. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Complex128Array} x - first input array +* @param {integer} strideX - `x` stride length +* @param {Complex128Array} y - second input array +* @param {integer} strideY - `y` stride length +* @returns {Complex128} dot product +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 7.0 ] ); +* var y = new Complex128Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 9.0 ] ); +* +* var z = zdotu( 3, x, 1, y, 1 ); +* // returns [ -52.0, 82.0 ] +*/ +function zdotu( N, x, strideX, y, strideY ) { + var viewX = reinterpret( x, 0 ); + var viewY = reinterpret( y, 0 ); + var obj = addon( N, viewX, strideX, viewY, strideY ); + return new Complex128( obj.re, obj.im ); +} + + +// EXPORTS // + +module.exports = zdotu; diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/manifest.json b/lib/node_modules/@stdlib/blas/base/zdotu/manifest.json new file mode 100644 index 000000000000..48908243d241 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/manifest.json @@ -0,0 +1,488 @@ +{ + "options": { + "task": "build", + "os": "linux", + "blas": "", + "wasm": false + }, + "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", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/zdotu.f", + "./src/zdotusub.f", + "./src/zdotu_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/napi/create-complex-like", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/zdotu.c", + "./src/zdotu_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "", + "wasm": false, + "src": [ + "./src/zdotu.c", + "./src/zdotu_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "build", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zdotu_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/napi/create-complex-like", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "benchmark", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zdotu_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "examples", + "os": "linux", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zdotu_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "build", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/zdotu.f", + "./src/zdotusub.f", + "./src/zdotu_f.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/napi/create-complex-like", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/zdotu.c", + "./src/zdotu_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "", + "wasm": false, + "src": [ + "./src/zdotu.c", + "./src/zdotu_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "build", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/zdotu_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/napi/create-complex-like", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/zdotu_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "apple_accelerate_framework", + "wasm": false, + "src": [ + "./src/zdotu_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lblas" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "build", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zdotu_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/napi/create-complex-like", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "benchmark", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zdotu_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "examples", + "os": "mac", + "blas": "openblas", + "wasm": false, + "src": [ + "./src/zdotu_cblas.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lopenblas", + "-lpthread" + ], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/min-view-buffer-index", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "build", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/zdotu.c", + "./src/zdotu_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/blas/base/shared", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-complex128array", + "@stdlib/napi/create-complex-like", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "benchmark", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/zdotu.c", + "./src/zdotu_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "examples", + "os": "win", + "blas": "", + "wasm": false, + "src": [ + "./src/zdotu.c", + "./src/zdotu_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/real", + "@stdlib/complex/float64/imag" + ] + }, + { + "task": "build", + "os": "", + "blas": "", + "wasm": true, + "src": [ + "./src/zdotu.c", + "./src/zdotu_ndarray.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/package.json b/lib/node_modules/@stdlib/blas/base/zdotu/package.json new file mode 100644 index 000000000000..0574c05e284f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/package.json @@ -0,0 +1,85 @@ +{ + "name": "@stdlib/blas/base/zdotu", + "version": "0.0.0", + "description": "Compute the dot product of two double-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", + "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", + "level 1", + "linear", + "algebra", + "subroutines", + "zdotu", + "dot", + "product", + "dot product", + "scalar", + "scalar product", + "inner", + "inner product", + "vector", + "typed", + "array", + "ndarray", + "complex", + "complex128", + "double", + "float64", + "float64array" + ], + "__stdlib__": { + "wasm": false + } +} diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/src/Makefile b/lib/node_modules/@stdlib/blas/base/zdotu/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/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/base/zdotu/src/addon.c b/lib/node_modules/@stdlib/blas/base/zdotu/src/addon.c new file mode 100644 index 000000000000..34857d716b51 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/src/addon.c @@ -0,0 +1,81 @@ +/** +* @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/base/zdotu.h" +#include "stdlib/napi/export.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_complex128array.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/real.h" +#include "stdlib/complex/float64/imag.h" +#include "stdlib/napi/create_complex_like.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_complex128_t v; + + STDLIB_NAPI_ARGV( env, info, argv, argc, 5 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, X, N, strideX, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 4 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, Y, N, strideY, argv, 3 ); + + API_SUFFIX(c_zdotu)( N, (void *)X, strideX, (void *)Y, strideY, (void *)&v ); + + STDLIB_NAPI_CREATE_COMPLEX_LIKE( env, stdlib_complex128_real( v ), stdlib_complex128_imag( v ), out ); + + return out; +} + +/** +* 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_complex128_t v; + + STDLIB_NAPI_ARGV( env, info, argv, argc, 7 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, X, N, strideX, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, offsetY, argv, 6 ); + STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, Y, N, strideY, argv, 4 ); + + API_SUFFIX(c_zdotu_ndarray)( N, (void *)X, strideX, offsetX, (void *)Y, strideY, offsetY, (void *)&v ); + + STDLIB_NAPI_CREATE_COMPLEX_LIKE( env, stdlib_complex128_real( v ), stdlib_complex128_imag( v ), out ); + + return out; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotu.c b/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotu.c new file mode 100644 index 000000000000..73278dfb5d9e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotu.c @@ -0,0 +1,37 @@ +/** +* @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/base/zdotu.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" + +/** +* Calculates the dot product of two double-precision complex floating-point vectors. +* +* @param N number of indexed elements +* @param X first input array +* @param strideX X stride length +* @param Y second input array +* @param strideY Y stride length +* @param dot output variable reference +*/ +void API_SUFFIX(c_zdotu)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const void *Y, const CBLAS_INT strideY, void *dot ) { + CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + CBLAS_INT oy = stdlib_strided_stride2offset( N, strideY ); + API_SUFFIX(c_zdotu_ndarray)( N, X, strideX, ox, Y, strideY, oy, dot ); +} diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotu.f b/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotu.f new file mode 100644 index 000000000000..421c798cc697 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotu.f @@ -0,0 +1,101 @@ +!> +! @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. +!< + +!> Calculates the dot product of two double-precision complex floating-point vectors. +! +! ## Notes +! +! * Modified version of reference BLAS level1 routine (version 3.7.0). Updated to "free form" Fortran 95. +! +! ## Authors +! +! * Univ. of Tennessee +! * Univ. of California Berkeley +! * Univ. of Colorado Denver +! * NAG Ltd. +! +! ## History +! +! * Jack Dongarra, linpack, 3/11/78. +! +! - modified 12/3/93, array(1) declarations changed to array(*) +! +! ## License +! +! From : +! +! > The reference BLAS is a freely-available software package. It is available from netlib via anonymous ftp and the World Wide Web. Thus, it can be included in commercial software packages (and has been). We only ask that proper credit be given to the authors. +! > +! > Like all software, it is copyrighted. It is not trademarked, but we do ask the following: +! > +! > * If you modify the source for these routines we ask that you change the name of the routine and comment the changes made to the original. +! > +! > * We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support. +! +! @param {integer} N - number of indexed elements +! @param {Array} cx - first input array +! @param {integer} strideX - `cx` stride length +! @param {Array} cy - second input array +! @param {integer} strideY - `cy` stride length +! @returns {complex} dot product +!< +complex(kind=kind(0.0d0)) function zdotu( N, cx, strideX, cy, strideY ) + implicit none + ! .. + ! Scalar arguments: + integer :: strideX, strideY, N + ! .. + ! Array arguments: + complex(kind=kind(0.0d0)), intent(in) :: cx(*), cy(*) + ! .. + ! Local scalars: + complex(kind=kind(0.0d0)) :: ctemp + integer :: i, ix, iy + ! .. + ctemp = (0.0d0,0.0d0) + zdotu = (0.0d0,0.0d0) + if ( N <= 0 ) then + return + end if + ! .. + if ( strideX == 1 .AND. strideY == 1 ) then + ! .. + ! Code for both increments equal to 1... + do i = 1, N + ctemp = ctemp + cx( i ) * cy( i ) + end do + else + ! .. + ! Code for unequal increments or equal increments not equal to 1... + ix = 1 + iy = 1 + if ( strideX < 0 ) then + ix = ( -N + 1 ) * strideX + 1 + end if + if ( strideY < 0 ) then + iy = ( -N + 1 ) * strideY + 1 + end if + do i = 1, N + ctemp = ctemp + cx( ix ) * cy( iy ) + ix = ix + strideX + iy = iy + strideY + end do + end if + zdotu = ctemp + return +end function zdotu diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotu_cblas.c b/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotu_cblas.c new file mode 100644 index 000000000000..0b1826d30260 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotu_cblas.c @@ -0,0 +1,58 @@ +/** +* @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/base/zdotu.h" +#include "stdlib/blas/base/zdotu_cblas.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/strided/base/min_view_buffer_index.h" + +/** +* Calculates the dot product of two double-precision complex floating-point vectors. +* +* @param N number of indexed elements +* @param X first input array +* @param strideX X stride length +* @param Y second input array +* @param strideY Y stride length +* @param dot output variable reference +*/ +void API_SUFFIX(c_zdotu)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const void *Y, const CBLAS_INT strideY, void *dot ) { + API_SUFFIX(cblas_zdotu_sub)( N, X, strideX, Y, strideY, dot ); +} + +/** +* Calculates the dot product of two double-precision complex floating-point vectors using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X first input array +* @param strideX X stride length +* @param offsetX starting index for X +* @param Y second input array +* @param strideY Y stride length +* @param offsetY starting index for Y +* @param dot output variable reference +*/ +void API_SUFFIX(c_zdotu_ndarray)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const void *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, void *dot ) { + const stdlib_complex128_t *x = (const stdlib_complex128_t *)X; + const stdlib_complex128_t *y = (const stdlib_complex128_t *)Y; + + x += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer + y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer + API_SUFFIX(cblas_zdotu_sub)( N, (const void *)x, strideX, (const void *)y, strideY, dot ); +} diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotu_f.c b/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotu_f.c new file mode 100644 index 000000000000..fb8d101243e2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotu_f.c @@ -0,0 +1,63 @@ +/** +* @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/base/zdotu.h" +#include "stdlib/blas/base/zdotu_fortran.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/min_view_buffer_index.h" + +/** +* Calculates the dot product of two double-precision complex floating-point vectors. +* +* @param N number of indexed elements +* @param X first input array +* @param strideX X stride length +* @param Y second input array +* @param strideY Y stride length +* @param dot output variable reference +*/ +void API_SUFFIX(c_zdotu)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const void *Y, const CBLAS_INT strideY, void *dot ) { + CBLAS_INT fN = N; + CBLAS_INT fstrideX = strideX; + CBLAS_INT fstrideY = strideY; + zdotusub( &fN, X, &fstrideX, Y, &fstrideY, dot ); +} + +/** +* Calculates the dot product of two double-precision complex floating-point vectors using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X first input array +* @param strideX X stride length +* @param offsetX starting index for X +* @param Y second input array +* @param strideY Y stride length +* @param offsetY starting index for Y +* @param dot output variable reference +*/ +void API_SUFFIX(c_zdotu_ndarray)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const void *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, void *dot ) { + const double *x = (const double *)X; + const double *y = (const double *)Y; + CBLAS_INT fN = N; + CBLAS_INT fstrideX = strideX; + CBLAS_INT fstrideY = strideY; + + x += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ) * 2; + y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ) * 2; + zdotusub( &fN, (const void *)x, &fstrideX, (const void *)y, &fstrideY, dot ); +} diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotu_ndarray.c b/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotu_ndarray.c new file mode 100644 index 000000000000..b2eb4fcca5f5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotu_ndarray.c @@ -0,0 +1,66 @@ +/** +* @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/base/zdotu.h" +#include "stdlib/blas/base/shared.h" + +/** +* Calculates the dot product of two double-precision complex floating-point vectors using alternative indexing semantics. +* +* @param N number of indexed elements +* @param X first input array +* @param strideX X stride length +* @param offsetX starting index for X +* @param Y second input array +* @param strideY Y stride length +* @param offsetY starting index for Y +* @param dot output variable reference +*/ +void API_SUFFIX(c_zdotu_ndarray)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const void *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY, void *dot ) { + const double *x = (const double *)X; + const double *y = (const double *)Y; + double *out = (double *)dot; + CBLAS_INT sx; + CBLAS_INT sy; + CBLAS_INT ix; + CBLAS_INT iy; + CBLAS_INT i; + double dr; + double di; + + out[ 0 ] = 0.0; + out[ 1 ] = 0.0; + if ( N <= 0 ) { + return; + } + sx = strideX * 2; + sy = strideY * 2; + ix = offsetX * 2; + iy = offsetY * 2; + + dr = 0.0; + di = 0.0; + for ( i = 0; i < N; i++ ) { + dr += ( x[ ix ] * y[ iy ] ) - ( x[ ix+1 ] * y[ iy+1 ] ); + di += ( x[ ix ] * y[ iy+1 ] ) + ( x[ ix+1 ] * y[ iy ] ); + ix += sx; + iy += sy; + } + out[ 0 ] = dr; + out[ 1 ] = di; +} diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotusub.f b/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotusub.f new file mode 100644 index 000000000000..888b015c0e3a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/src/zdotusub.f @@ -0,0 +1,49 @@ +!> +! @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. +!< + +!> Wraps `zdotu` as a subroutine. +! +! @param {integer} N - number of indexed elements +! @param {Array} cx - first input array +! @param {integer} strideX - `cx` stride length +! @param {Array} cy - second input array +! @param {integer} strideY - `cy` stride length +! @param {complex} dot - output variable reference +!< +subroutine zdotusub( N, cx, strideX, cy, strideY, dot ) + implicit none + ! .. + ! External functions: + interface + complex(kind=kind(0.0d0)) function zdotu( N, cx, strideX, cy, strideY ) + complex(kind=kind(0.0d0)), intent(in) :: cx(*), cy(*) + integer :: strideX, strideY, N + end function zdotu + end interface + ! .. + ! Scalar arguments: + integer :: strideX, strideY, N + complex(kind=kind(0.0d0)) :: dot + ! .. + ! Array arguments: + complex(kind=kind(0.0d0)), intent(in) :: cx(*), cy(*) + ! .. + ! Find the dot product: + dot = zdotu( N, cx, strideX, cy, strideY ) + return +end subroutine zdotusub diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/test/test.js b/lib/node_modules/@stdlib/blas/base/zdotu/test/test.js new file mode 100644 index 000000000000..2255b352d7ab --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/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 zdotu = 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 zdotu, '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 zdotu.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 zdotu = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( zdotu, 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 zdotu; + var main; + + main = require( './../lib/zdotu.js' ); + + zdotu = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( zdotu, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/zdotu/test/test.ndarray.js new file mode 100644 index 000000000000..16dd651bd143 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/test/test.ndarray.js @@ -0,0 +1,239 @@ +/** +* @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 Complex128 = require( '@stdlib/complex/float64/ctor' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var isSameComplex128 = require( '@stdlib/assert/is-same-complex128' ); +var zdotu = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zdotu, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( zdotu.length, 7, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the dot product of two single-precision complex floating-point vectors `x` and `y`', function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 2.0, -5.0, 6.0 ] ); + y = new Complex128Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 8.0, 2.0, -3.0 ] ); + + dot = zdotu( x.length, x, 1, 0, y, 1, 0 ); + t.strictEqual(isSameComplex128( dot, new Complex128( 3.0, 70.0 ) ), true, 'returns expected value' ); + + x = new Complex128Array( [ 3.0, -4.0, 1.0, 2.0 ] ); + y = new Complex128Array( [ 1.0, -2.0, 3.0, 8.0 ] ); + + dot = zdotu( x.length, x, 1, 0, y, 1, 0 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -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 x; + var y; + + x = new Complex128Array( [ 3.0, -4.0, 1.0, 7.0 ] ); + y = new Complex128Array( [ 1.0, -2.0, 3.0, -3.0 ] ); + + dot = zdotu( 0, x, 1, 0, y, 1, 0 ); + t.strictEqual( isSameComplex128( dot, new Complex128( 0, 0 ) ), true, 'returns expected value' ); + + dot = zdotu( -4, x, 1, 0, y, 1, 0 ); + t.strictEqual( isSameComplex128( dot, new Complex128( 0, 0 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 2.0, // 0 + -3.0, // 0 + -5.0, + 6.0, + 7.0, // 1 + 6.0 // 1 + ]); + y = new Complex128Array([ + 8.0, // 0 + 2.0, // 0 + -3.0, // 1 + 3.0, // 1 + -4.0, + 1.0 + ]); + + dot = zdotu( 2, x, 2, 0, y, 1, 0 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -17, -17 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` offset', function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 2.0, + -3.0, + -5.0, // 0 + 6.0, // 0 + 7.0, // 1 + 6.0 // 1 + ]); + y = new Complex128Array([ + 8.0, // 0 + 2.0, // 0 + -3.0, // 1 + 3.0, // 1 + -4.0, + 1.0 + ]); + + dot = zdotu( 2, x, 1, 1, y, 1, 0 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -91, 41 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` stride', function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 2.0, // 0 + -3.0, // 0 + -5.0, // 1 + 6.0, // 1 + 7.0, + 6.0 + ]); + y = new Complex128Array([ + 8.0, // 0 + 2.0, // 0 + -3.0, + 3.0, + -4.0, // 1 + 1.0 // 1 + ]); + + dot = zdotu( 2, x, 1, 0, y, 2, 0 ); + t.strictEqual( isSameComplex128( dot, new Complex128( 36, -49 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset', function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0 // 1 + ]); + y = new Complex128Array([ + 7.0, + 8.0, + 9.0, // 0 + 10.0, // 0 + 11.0, // 1 + 12.0 // 1 + ]); + + dot = zdotu( 2, x, 2, 0, y, 1, 1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -28, 154 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 0 + 6.0 // 0 + ]); + y = new Complex128Array([ + 7.0, + 8.0, + 9.0, // 1 + 10.0, // 1 + 11.0, // 0 + 12.0 // 0 + ]); + + dot = zdotu( 2, x, -2, x.length-1, y, -1, 2 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -28, 154 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0 // 1 + ]); + y = new Complex128Array([ + 7.0, // 1 + 8.0, // 1 + 9.0, // 0 + 10.0, // 0 + 11.0, + 12.0 + ]); + + dot = zdotu( 2, x, 2, 0, y, -1, y.length-2 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -24, 110 ) ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/base/zdotu/test/test.ndarray.native.js new file mode 100644 index 000000000000..dddeeb0cc4d7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/test/test.ndarray.native.js @@ -0,0 +1,248 @@ +/** +* @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 Complex128 = require( '@stdlib/complex/float64/ctor' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var isSameComplex128 = require( '@stdlib/assert/is-same-complex128' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var zdotu = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( zdotu instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zdotu, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', opts, function test( t ) { + t.strictEqual( zdotu.length, 7, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the dot product of two single-precision complex floating-point vectors `x` and `y`', opts, function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 2.0, -5.0, 6.0 ] ); + y = new Complex128Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 8.0, 2.0, -3.0 ] ); + + dot = zdotu( x.length, x, 1, 0, y, 1, 0 ); + t.strictEqual(isSameComplex128( dot, new Complex128( 3.0, 70.0 ) ), true, 'returns expected value' ); + + x = new Complex128Array( [ 3.0, -4.0, 1.0, 2.0 ] ); + y = new Complex128Array( [ 1.0, -2.0, 3.0, 8.0 ] ); + + dot = zdotu( x.length, x, 1, 0, y, 1, 0 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -18, 4 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', opts, function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array( [ 3.0, -4.0, 1.0, 7.0 ] ); + y = new Complex128Array( [ 1.0, -2.0, 3.0, -3.0 ] ); + + dot = zdotu( 0, x, 1, 0, y, 1, 0 ); + t.strictEqual( isSameComplex128( dot, new Complex128( 0, 0 ) ), true, 'returns expected value' ); + + dot = zdotu( -4, x, 1, 0, y, 1, 0 ); + t.strictEqual( isSameComplex128( dot, new Complex128( 0, 0 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 2.0, // 0 + -3.0, // 0 + -5.0, + 6.0, + 7.0, // 1 + 6.0 // 1 + ]); + y = new Complex128Array([ + 8.0, // 0 + 2.0, // 0 + -3.0, // 1 + 3.0, // 1 + -4.0, + 1.0 + ]); + + dot = zdotu( 2, x, 2, 0, y, 1, 0 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -17, -17 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` offset', opts, function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 2.0, + -3.0, + -5.0, // 0 + 6.0, // 0 + 7.0, // 1 + 6.0 // 1 + ]); + y = new Complex128Array([ + 8.0, // 0 + 2.0, // 0 + -3.0, // 1 + 3.0, // 1 + -4.0, + 1.0 + ]); + + dot = zdotu( 2, x, 1, 1, y, 1, 0 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -91, 41 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` stride', opts, function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 2.0, // 0 + -3.0, // 0 + -5.0, // 1 + 6.0, // 1 + 7.0, + 6.0 + ]); + y = new Complex128Array([ + 8.0, // 0 + 2.0, // 0 + -3.0, + 3.0, + -4.0, // 1 + 1.0 // 1 + ]); + + dot = zdotu( 2, x, 1, 0, y, 2, 0 ); + t.strictEqual( isSameComplex128( dot, new Complex128( 36, -49 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` offset', opts, function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0 // 1 + ]); + y = new Complex128Array([ + 7.0, + 8.0, + 9.0, // 0 + 10.0, // 0 + 11.0, // 1 + 12.0 // 1 + ]); + + dot = zdotu( 2, x, 2, 0, y, 1, 1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -28, 154 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', opts, function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 0 + 6.0 // 0 + ]); + y = new Complex128Array([ + 7.0, + 8.0, + 9.0, // 1 + 10.0, // 1 + 11.0, // 0 + 12.0 // 0 + ]); + + dot = zdotu( 2, x, -2, x.length-1, y, -1, 2 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -28, 154 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', opts, function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0 // 1 + ]); + y = new Complex128Array([ + 7.0, // 1 + 8.0, // 1 + 9.0, // 0 + 10.0, // 0 + 11.0, + 12.0 + ]); + + dot = zdotu( 2, x, 2, 0, y, -1, y.length-2 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -24, 110 ) ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/test/test.zdotu.js b/lib/node_modules/@stdlib/blas/base/zdotu/test/test.zdotu.js new file mode 100644 index 000000000000..f107818aeeb4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/test/test.zdotu.js @@ -0,0 +1,217 @@ +/** +* @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 Complex128 = require( '@stdlib/complex/float64/ctor' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var isSameComplex128 = require( '@stdlib/assert/is-same-complex128' ); +var zdotu = require( './../lib/zdotu.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zdotu, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( zdotu.length, 5, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the dot product of two single-precision complex floating-point vectors `x` and `y`', function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 2.0, -5.0, 6.0 ] ); + y = new Complex128Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 8.0, 2.0, -3.0 ] ); + + dot = zdotu( 4, x, 1, y, 1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( 3.0, 70.0 ) ), true, 'returns expected value' ); + + x = new Complex128Array( [ 3.0, -4.0, 1.0, 2.0 ] ); + y = new Complex128Array( [ 1.0, -2.0, 3.0, 8.0 ] ); + + dot = zdotu( 2, x, 1, y, 1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -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 x; + var y; + + x = new Complex128Array( [ 3.0, -4.0, 1.0, 7.0 ] ); + y = new Complex128Array( [ 1.0, -2.0, 3.0, -3.0 ] ); + + dot = zdotu( 0, x, 1, y, 1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( 0, 0 ) ), true, 'returns expected value' ); + + dot = zdotu( -4, x, 1, y, 1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( 0, 0 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 2.0, // 0 + -3.0, // 0 + -5.0, + 6.0, + 7.0, // 1 + 6.0 // 1 + ]); + y = new Complex128Array([ + 8.0, // 0 + 2.0, // 0 + -3.0, // 1 + 3.0, // 1 + -4.0, + 1.0 + ]); + + dot = zdotu( 2, x, 2, y, 1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -17, -17 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` stride', function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 2.0, // 0 + -3.0, // 0 + -5.0, // 1 + 7.0, // 1 + 6.0, + -2.0 + ]); + y = new Complex128Array([ + 8.0, // 0 + 2.0, // 0 + -3.0, + 3.0, + -4.0, // 1 + 1.0 // 1 + ]); + + dot = zdotu( 2, x, 1, y, 2 ); + t.strictEqual( isSameComplex128( dot, new Complex128( 35, -53 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 0 + 6.0 // 0 + ]); + y = new Complex128Array([ + 7.0, // 1 + 8.0, // 1 + 9.0, // 0 + 10.0, // 0 + 11.0, + 12.0 + ]); + + dot = zdotu( 2, x, -2, y, -1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -24, 126 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0 // 1 + ]); + y = new Complex128Array([ + 7.0, // 1 + 8.0, // 1 + 9.0, // 0 + 10.0, // 0 + 11.0, + 12.0 + ]); + + dot = zdotu( 2, x, 2, y, -1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -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 Complex128Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0 // 1 + ]); + y0 = new Complex128Array([ + 7.0, + 8.0, + 9.0, // 0 + 10.0, // 0 + 11.0, // 1 + 12.0 // 1 + ]); + + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*0 ); + y1 = new Complex128Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); + + dot = zdotu( 2, x1, 2, y1, 1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -28, 154 ) ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/zdotu/test/test.zdotu.native.js b/lib/node_modules/@stdlib/blas/base/zdotu/test/test.zdotu.native.js new file mode 100644 index 000000000000..17259d56bde5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/zdotu/test/test.zdotu.native.js @@ -0,0 +1,226 @@ +/** +* @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 Complex128 = require( '@stdlib/complex/float64/ctor' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var isSameComplex128 = require( '@stdlib/assert/is-same-complex128' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var zdotu = tryRequire( resolve( __dirname, './../lib/zdotu.js' ) ); +var opts = { + 'skip': ( zdotu instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof zdotu, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', opts, function test( t ) { + t.strictEqual( zdotu.length, 5, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the dot product of two single-precision complex floating-point vectors `x` and `y`', opts, function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array( [ 4.0, 2.0, -3.0, 5.0, -1.0, 2.0, -5.0, 6.0 ] ); + y = new Complex128Array( [ 2.0, 6.0, -1.0, -4.0, 8.0, 8.0, 2.0, -3.0 ] ); + + dot = zdotu( 4, x, 1, y, 1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( 3.0, 70.0 ) ), true, 'returns expected value' ); + + x = new Complex128Array( [ 3.0, -4.0, 1.0, 2.0 ] ); + y = new Complex128Array( [ 1.0, -2.0, 3.0, 8.0 ] ); + + dot = zdotu( 2, x, 1, y, 1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -18, 4 ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `0`', opts, function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array( [ 3.0, -4.0, 1.0, 7.0 ] ); + y = new Complex128Array( [ 1.0, -2.0, 3.0, -3.0 ] ); + + dot = zdotu( 0, x, 1, y, 1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( 0, 0 ) ), true, 'returns expected value' ); + + dot = zdotu( -4, x, 1, y, 1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( 0, 0 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `x` stride', opts, function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 2.0, // 0 + -3.0, // 0 + -5.0, + 6.0, + 7.0, // 1 + 6.0 // 1 + ]); + y = new Complex128Array([ + 8.0, // 0 + 2.0, // 0 + -3.0, // 1 + 3.0, // 1 + -4.0, + 1.0 + ]); + + dot = zdotu( 2, x, 2, y, 1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -17, -17 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `y` stride', opts, function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 2.0, // 0 + -3.0, // 0 + -5.0, // 1 + 7.0, // 1 + 6.0, + -2.0 + ]); + y = new Complex128Array([ + 8.0, // 0 + 2.0, // 0 + -3.0, + 3.0, + -4.0, // 1 + 1.0 // 1 + ]); + + dot = zdotu( 2, x, 1, y, 2 ); + t.strictEqual( isSameComplex128( dot, new Complex128( 35, -53 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', opts, function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 1.0, // 1 + 2.0, // 1 + 3.0, + 4.0, + 5.0, // 0 + 6.0 // 0 + ]); + y = new Complex128Array([ + 7.0, // 1 + 8.0, // 1 + 9.0, // 0 + 10.0, // 0 + 11.0, + 12.0 + ]); + + dot = zdotu( 2, x, -2, y, -1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -24, 126 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', opts, function test( t ) { + var dot; + var x; + var y; + + x = new Complex128Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0 // 1 + ]); + y = new Complex128Array([ + 7.0, // 1 + 8.0, // 1 + 9.0, // 0 + 10.0, // 0 + 11.0, + 12.0 + ]); + + dot = zdotu( 2, x, 2, y, -1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -24, 110 ) ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var dot; + var x0; + var y0; + var x1; + var y1; + + x0 = new Complex128Array([ + 1.0, // 0 + 2.0, // 0 + 3.0, + 4.0, + 5.0, // 1 + 6.0 // 1 + ]); + y0 = new Complex128Array([ + 7.0, + 8.0, + 9.0, // 0 + 10.0, // 0 + 11.0, // 1 + 12.0 // 1 + ]); + + x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*0 ); + y1 = new Complex128Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); + + dot = zdotu( 2, x1, 2, y1, 1 ); + t.strictEqual( isSameComplex128( dot, new Complex128( -28, 154 ) ), true, 'returns expected value' ); + t.end(); +});