From 54c5e1777052e0f43352e0bf6772dc7ad696c11f Mon Sep 17 00:00:00 2001 From: Neeraj Pathak Date: Wed, 28 Jan 2026 16:27:39 +0530 Subject: [PATCH] feat: add initial setup --- .../complex/float64/base/add4/README.md | 284 +++++++++ .../base/add4/benchmark/benchmark.assign.js | 71 +++ .../float64/base/add4/benchmark/benchmark.js | 60 ++ .../base/add4/benchmark/benchmark.native.js | 70 +++ .../base/add4/benchmark/benchmark.strided.js | 72 +++ .../float64/base/add4/benchmark/c/Makefile | 126 ++++ .../float64/base/add4/benchmark/c/benchmark.c | 154 +++++ .../base/add4/benchmark/c/native/Makefile | 146 +++++ .../base/add4/benchmark/c/native/benchmark.c | 158 +++++ .../float64/base/add4/benchmark/julia/REQUIRE | 2 + .../base/add4/benchmark/julia/benchmark.jl | 144 +++++ .../complex/float64/base/add4/binding.gyp | 170 +++++ .../complex/float64/base/add4/docs/repl.txt | 152 +++++ .../float64/base/add4/docs/types/index.d.ts | 154 +++++ .../float64/base/add4/docs/types/test.ts | 583 ++++++++++++++++++ .../float64/base/add4/examples/c/Makefile | 146 +++++ .../float64/base/add4/examples/c/example.c | 46 ++ .../float64/base/add4/examples/index.js | 33 + .../complex/float64/base/add4/include.gypi | 53 ++ .../stdlib/complex/float64/base/add4.h | 40 ++ .../complex/float64/base/add4/lib/assign.js | 54 ++ .../complex/float64/base/add4/lib/index.js | 54 ++ .../complex/float64/base/add4/lib/main.js | 56 ++ .../complex/float64/base/add4/lib/native.js | 55 ++ .../complex/float64/base/add4/lib/strided.js | 63 ++ .../complex/float64/base/add4/manifest.json | 75 +++ .../complex/float64/base/add4/package.json | 68 ++ .../complex/float64/base/add4/src/Makefile | 70 +++ .../complex/float64/base/add4/src/addon.c | 22 + .../complex/float64/base/add4/src/main.c | 68 ++ .../float64/base/add4/test/test.assign.js | 132 ++++ .../complex/float64/base/add4/test/test.js | 46 ++ .../float64/base/add4/test/test.main.js | 130 ++++ .../float64/base/add4/test/test.native.js | 139 +++++ .../float64/base/add4/test/test.strided.js | 184 ++++++ 35 files changed, 3880 insertions(+) create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/README.md create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/benchmark.assign.js create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/benchmark.strided.js create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/julia/REQUIRE create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/julia/benchmark.jl create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/binding.gyp create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/examples/index.js create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/include.gypi create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/include/stdlib/complex/float64/base/add4.h create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/lib/assign.js create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/lib/index.js create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/lib/main.js create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/lib/native.js create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/lib/strided.js create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/manifest.json create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/package.json create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/src/Makefile create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/src/addon.c create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/src/main.c create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/test/test.assign.js create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/test/test.js create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/test/test.main.js create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/test/test.native.js create mode 100644 lib/node_modules/@stdlib/complex/float64/base/add4/test/test.strided.js diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/README.md b/lib/node_modules/@stdlib/complex/float64/base/add4/README.md new file mode 100644 index 000000000000..0653a9a358dd --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/README.md @@ -0,0 +1,284 @@ + + +# add4 + +> Compute the sum of four double-precision complex floating-point numbers. + +
+ +
+ + + +
+ +## Usage + +```javascript +var add4 = require( '@stdlib/complex/float64/base/add4' ); +``` + +#### add4( z1, z2, z3, z4 ) + +Computes the sum of four double-precision complex floating-point numbers. + +```javascript +var Complex128 = require( '@stdlib/complex/float64/ctor' ); + +var z = new Complex128( -1.5, 2.5 ); + +var v = add4( z, z, z, z ); +// returns [ -7.5, 12.5 ] +``` + +The function supports the following parameters: + +- **z1**: first complex number. +- **z2**: second complex number. +- **z3**: third complex number. +- **z4**: fourth complex number. + +#### add4.assign( re1, im1, re2, im2, re3, im3, re4, im4, out, strideOut, offsetOut ) + +Computes the sum of four double-precision complex floating-point numbers and assigns results to a provided output array. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var out = new Float64Array( 2 ); +var v = add4.assign( 5.0, 3.0, -2.0, 1.0, 5.0, 3.0, 1.0, 4.0, out, 1, 0 ); +// returns [ 9.0, 11.0 ] + +var bool = ( out === v ); +// returns true +``` + +The function supports the following parameters: + +- **re1**: real component of the first complex number. +- **im1**: imaginary component of the first complex number. +- **re2**: real component of the second complex number. +- **im2**: imaginary component of the second complex number. +- **re3**: real component of the third complex number. +- **im3**: imaginary component of the third complex number. +- **re4**: real component of the fourth complex number. +- **im4**: imaginary component of the fourth complex number. +- **out**: output array. +- **strideOut**: stride length for `out`. +- **offsetOut**: starting index for `out`. + +#### add4.strided( z1, sz1, oz1, z2, sz2, oz2, z3, sz3, oz3, z4, sz4, oz4, out, so, oo ) + +Computes the sum of four double-precision complex floating-point numbers stored in real-valued strided array views and assigns results to a provided strided output array. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var z1 = new Float64Array( [ 5.0, 3.0 ] ); +var z2 = new Float64Array( [ -2.0, 1.0 ] ); +var z3 = new Float64Array( [ 5.0, 3.0 ] ); +var z4 = new Float64Array( [ 1.0, 4.0 ] ); +var out = new Float64Array( 2 ); + +var v = add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); +// returns [ 9.0, 11.0 ] + +var bool = ( out === v ); +// returns true +``` + +The function supports the following parameters: + +- **z1**: first complex number strided array view. +- **sz1**: stride length for `z1`. +- **oz1**: starting index for `z1`. +- **z2**: second complex number strided array view. +- **sz2**: stride length for `z2`. +- **oz2**: starting index for `z2`. +- **z3**: third complex number strided array view. +- **sz3**: stride length for `z3`. +- **oz3**: starting index for `z3`. +- **z4**: fourth complex number strided array view. +- **sz4**: stride length for `z4`. +- **oz4**: starting index for `z4`. +- **out**: output array. +- **so**: stride length for `out`. +- **oo**: starting index for `out`. + +
+ + + +
+ +## Examples + + + +```javascript +var Complex128Array = require( '@stdlib/array/complex128' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var add4 = require( '@stdlib/complex/float64/base/add4' ); + +// Generate arrays of random values: +var z1 = new Complex128Array( discreteUniform( 200, -50, 50 ) ); +var z2 = new Complex128Array( discreteUniform( 200, -50, 50 ) ); +var z3 = new Complex128Array( discreteUniform( 200, -50, 50 ) ); +var z4 = new Complex128Array( discreteUniform( 200, -50, 50 ) ); + +// Perform element-wise addition: +logEachMap( '(%s) + (%s) + (%s) + (%s) = %s', z1, z2, z3, z4, add4 ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/complex/float64/base/add4.h" +``` + +#### stdlib_base_complex128_add4( z1, z2, z3, z4 ) + +Computes the sum of four double-precision complex floating-point numbers. + +```c +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/real.h" +#include "stdlib/complex/float64/imag.h" + +stdlib_complex128_t z = stdlib_complex128( 3.0, -2.0 ); + +stdlib_complex128_t out = stdlib_base_complex128_add4( z, z, z, z ); + +double re = stdlib_complex128_real( out ); +// returns 12.0 + +double im = stdlib_complex128_imag( out ); +// returns -8.0 +``` + +The function accepts the following arguments: + +- **z1**: `[in] stdlib_complex128_t` first input value. +- **z2**: `[in] stdlib_complex128_t` second input value. +- **z3**: `[in] stdlib_complex128_t` third input value. +- **z4**: `[in] stdlib_complex128_t` fourth input value. + +```c +stdlib_complex128_t stdlib_base_complex128_add4( const stdlib_complex128_t z1, const stdlib_complex128_t z2, const stdlib_complex128_t z3, const stdlib_complex128_t z4 ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/complex/float64/base/add4.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" +#include + +int main( void ) { + const stdlib_complex128_t x[] = { + stdlib_complex128( 3.14, 1.5 ), + stdlib_complex128( -3.14, 1.5 ), + stdlib_complex128( 0.0, -0.0 ), + stdlib_complex128( 0.0/0.0, 0.0/0.0 ) + }; + + stdlib_complex128_t v; + stdlib_complex128_t y; + double re; + double im; + int i; + for ( i = 0; i < 4; i++ ) { + v = x[ i ]; + stdlib_complex128_reim( v, &re, &im ); + printf( "z = %lf + %lfi\n", re, im ); + + y = stdlib_base_complex128_add4( v, v, v, v ); + stdlib_complex128_reim( y, &re, &im ); + printf( "add4(z, z, z, z) = %lf + %lfi\n", re, im ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/benchmark.assign.js new file mode 100644 index 000000000000..0d65371e0c76 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/benchmark.assign.js @@ -0,0 +1,71 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var add4 = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// MAIN // + +bench( format( '%s:assign', pkg ), function benchmark( b ) { + var out; + var re; + var im; + var N; + var i; + var j; + var k; + + N = 100; + re = uniform( N, -500.0, 500.0, options ); + im = uniform( N, -500.0, 500.0, options ); + + out = new Float64Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + j = i % N; + k = ( i+1 ) % N; + out = add4.assign( re[ j ], im[ j ], re[ k ], im[ k ], re[ j ], im[ k ], re[ j ], im[ k ], out, 1, 0 ); // eslint-disable-line max-len + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/benchmark.js b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/benchmark.js new file mode 100644 index 000000000000..73c4eb08356e --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/benchmark.js @@ -0,0 +1,60 @@ +/** +* @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/base/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var pkg = require( './../package.json' ).name; +var add4 = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var out; + var z; + var i; + + values = [ + new Complex128( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ), + new Complex128( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = values[ i%values.length ]; + out = add4( z, z, z, z ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( isnan( real( out ) ) || isnan( imag( out ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/benchmark.native.js new file mode 100644 index 000000000000..9535913685af --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/benchmark.native.js @@ -0,0 +1,70 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var add4 = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( add4 instanceof Error ) +}; + + +// MAIN // + +bench( format( '%s::native', pkg ), opts, function benchmark( b ) { + var values; + var out; + var z; + var i; + + values = [ + new Complex128( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ), + new Complex128( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = values[ i%values.length ]; + out = add4( z, z, z, z ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( isnan( real( out ) ) || isnan( imag( out ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/benchmark.strided.js b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/benchmark.strided.js new file mode 100644 index 000000000000..6e2500ec0bb3 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/benchmark.strided.js @@ -0,0 +1,72 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var add4 = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// MAIN // + +bench( format( '%s:strided', pkg ), function benchmark( b ) { + var out; + var z1; + var z2; + var z3; + var N; + var i; + var j; + + N = 50; + z1 = uniform( N*2, -500.0, 500.0, options ); + z2 = uniform( N*2, -500.0, 500.0, options ); + z3 = uniform( N*2, -500.0, 500.0, options ); + z4 = uniform( N*2, -500.0, 500.0, options ); + + out = new Float64Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + j = ( i % N ) * 2; + out = add4.strided( z1, 1, j, z2, 1, j, z3, 1, j, z4, 1, j, out, 1, 0 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/c/Makefile b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/c/Makefile new file mode 100644 index 000000000000..ff0ad2332400 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/c/Makefile @@ -0,0 +1,126 @@ +#/ +# @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 C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles C source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code (e.g., `-fPIC`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler +# @param {string} CFLAGS - C compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) -o $@ $< -lm + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/c/benchmark.c new file mode 100644 index 000000000000..717a25ca0b41 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/c/benchmark.c @@ -0,0 +1,154 @@ +/** +* @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 +#include +#include +#include +#include + +#define NAME "add4" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +static void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double complex z1[ 100 ]; + double complex z2[ 100 ]; + double complex z3[ 100 ]; + double complex z4[ 100 ]; + double complex z5; + double elapsed; + double re; + double im; + double t; + int i; + + for ( i = 0; i < 100; i++ ) { + re = ( 1000.0*rand_double() ) - 500.0; + im = ( 1000.0*rand_double() ) - 500.0; + z1[ i ] = re + im*I; + + re = ( 1000.0*rand_double() ) - 500.0; + im = ( 1000.0*rand_double() ) - 500.0; + z2[ i ] = re + im*I; + + re = ( 1000.0*rand_double() ) - 500.0; + im = ( 1000.0*rand_double() ) - 500.0; + z3[ i ] = re + im*I; + + re = ( 1000.0*rand_double() ) - 500.0; + im = ( 1000.0*rand_double() ) - 500.0; + z4[ i ] = re + im*I; + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + z4 = (creal(z1[i%100])+creal(z2[i%100])+creal(z3[i%100])+creal(z4[i%100])) + (cimag(z1[i%100])+cimag(z2[i%100])+cimag(z3[i%100])+cimag(z4[i%100]))*I; + if ( z5 != z5 ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( z5 != z5 ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/c/native/Makefile new file mode 100644 index 000000000000..979768abbcec --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/c/native/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..a153ba5ec2bd --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/c/native/benchmark.c @@ -0,0 +1,158 @@ +/** +* @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/complex/float64/base/add4.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" +#include +#include +#include +#include +#include + +#define NAME "add4" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +static void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + stdlib_complex128_t z1[ 100 ]; + stdlib_complex128_t z2[ 100 ]; + stdlib_complex128_t z3[ 100 ]; + stdlib_complex128_t z4[ 100 ]; + stdlib_complex128_t z5; + double elapsed; + double re; + double im; + double t; + int i; + + for ( i = 0; i < 100; i++ ) { + re = ( 1000.0*rand_double() ) - 500.0; + im = ( 1000.0*rand_double() ) - 500.0; + z1[ i ] = stdlib_complex128( re, im ); + + re = ( 1000.0*rand_double() ) - 500.0; + im = ( 1000.0*rand_double() ) - 500.0; + z2[ i ] = stdlib_complex128( re, im ); + + re = ( 1000.0*rand_double() ) - 500.0; + im = ( 1000.0*rand_double() ) - 500.0; + z3[ i ] = stdlib_complex128( re, im ); + + re = ( 1000.0*rand_double() ) - 500.0; + im = ( 1000.0*rand_double() ) - 500.0; + z4[ i ] = stdlib_complex128( re, im ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + z5 = stdlib_base_complex128_add4( z1[ i%100 ], z2[ i%100 ], z3[ i%100 ], z4[ i%100 ] ); + stdlib_complex128_reim( z5, &re, &im ); + if ( re != re ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( im != im ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::native::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/julia/REQUIRE b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/julia/REQUIRE new file mode 100644 index 000000000000..98645e192e41 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/julia/REQUIRE @@ -0,0 +1,2 @@ +julia 1.5 +BenchmarkTools 0.5.0 diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/julia/benchmark.jl b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/julia/benchmark.jl new file mode 100644 index 000000000000..9cb0d8994a03 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/benchmark/julia/benchmark.jl @@ -0,0 +1,144 @@ +#!/usr/bin/env julia +# +# @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 BenchmarkTools +using Printf + +# Benchmark variables: +name = "add4"; +repeats = 4; + +""" + print_version() + +Prints the TAP version. + +# Examples + +``` julia +julia> print_version() +``` +""" +function print_version() + @printf( "TAP version 13\n" ); +end + +""" + print_summary( total, passing ) + +Print the benchmark summary. + +# Arguments + +* `total`: total number of tests +* `passing`: number of passing tests + +# Examples + +``` julia +julia> print_summary( 4, 4 ) +``` +""" +function print_summary( total, passing ) + @printf( "#\n" ); + @printf( "1..%d\n", total ); # TAP plan + @printf( "# total %d\n", total ); + @printf( "# pass %d\n", passing ); + @printf( "#\n" ); + @printf( "# ok\n" ); +end + +""" + print_results( iterations, elapsed ) + +Print benchmark results. + +# Arguments + +* `iterations`: number of iterations +* `elapsed`: elapsed time (in seconds) + +# Examples + +``` julia +julia> print_results( 1000000, 0.131009101868 ) +``` +""" +function print_results( iterations, elapsed ) + rate = iterations / elapsed + + @printf( " ---\n" ); + @printf( " iterations: %d\n", iterations ); + @printf( " elapsed: %0.9f\n", elapsed ); + @printf( " rate: %0.9f\n", rate ); + @printf( " ...\n" ); +end + +""" + benchmark() + +Run a benchmark. + +# Notes + +* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. +* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. +* The elapsed time is in seconds. + +# Examples + +``` julia +julia> out = benchmark(); +``` +""" +function benchmark() + t = BenchmarkTools.@benchmark ComplexF64( (rand()*1000.0)-500.0, (rand()*1000.0)-500.0 ) + ComplexF64( (rand()*1000.0)-500.0, (rand()*1000.0)-500.0 ) + ComplexF64( (rand()*1000.0)-500.0, (rand()*1000.0)-500.0 ) + ComplexF64( (rand()*1000.0)-500.0, (rand()*1000.0)-500.0 ) samples=1e6 + + # Compute the total "elapsed" time and convert from nanoseconds to seconds: + s = sum( t.times ) / 1.0e9; + + # Determine the number of "iterations": + iter = length( t.times ); + + # Return the results: + [ iter, s ]; +end + +""" + main() + +Run benchmarks. + +# Examples + +``` julia +julia> main(); +``` +""" +function main() + print_version(); + for i in 1:repeats + @printf( "# julia::%s\n", name ); + results = benchmark(); + print_results( results[ 1 ], results[ 2 ] ); + @printf( "ok %d benchmark finished\n", i ); + end + print_summary( repeats, repeats ); +end + +main(); diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/binding.gyp b/lib/node_modules/@stdlib/complex/float64/base/add4/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/docs/repl.txt b/lib/node_modules/@stdlib/complex/float64/base/add4/docs/repl.txt new file mode 100644 index 000000000000..224652a397ee --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/docs/repl.txt @@ -0,0 +1,152 @@ + +{{alias}}( z1, z2, z3 ) + Computes the sum of four double-precision complex floating-point numbers. + + Parameters + ---------- + z1: Complex128 + Complex number. + + z2: Complex128 + Complex number. + + z3: Complex128 + Complex number. + + z4: Complex128 + Complex number. + + Returns + ------- + out: Complex128 + Result. + + Examples + -------- + > var z = new {{alias:@stdlib/complex/float64/ctor}}( 5.0, 3.0 ) + [ 5.0, 3.0 ] + > var out = {{alias}}( z, z, z, z ) + [ 20.0, 12.0 ] + + +{{alias}}.assign( re1, im1, re2, im2, re3, im3, re4, im4, out, strideOut, offsetOut ) + Computes the sum of four double-precision complex floating-point numbers + and assigns results to a provided output array. + + Parameters + ---------- + re1: number + Real component of the first complex number. + + im1: number + Imaginary component of the first complex number. + + re2: number + Real component of the second complex number. + + im2: number + Imaginary component of the second complex number. + + re3: number + Real component of the third complex number. + + im3: number + Imaginary component of the third complex number. + + re4: number + Real component of the fourth complex number. + + im4: number + Imaginary component of the fourth complex number. + + out: ArrayLikeObject + Output array. + + strideOut: integer + Stride length. + + offsetOut: integer + Starting index. + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples + -------- + > var out = new {{alias:@stdlib/array/float64}}( 2 ); + > {{alias}}.assign( 5.0, 3.0, 5.0, 3.0, 5.0, 3.0, 5.0, 3.0, out, 1, 0 ) + [ 20.0, 12.0 ] + + +{{alias}}.strided( z1, sz1, oz1, z2, sz2, oz2, z3, sz3, oz3, z4, sz4, oz4, out, so, oo ) + Computes the sum of four double-precision complex floating-point numbers + stored in real-valued strided array views and assigns results to a provided + strided output array. + + Parameters + ---------- + z1: ArrayLikeObject + First complex number view. + + sz1: integer + Stride length for `z1`. + + oz1: integer + Starting index for `z1`. + + z2: ArrayLikeObject + Second complex number view. + + sz2: integer + Stride length for `z2`. + + oz2: integer + Starting index for `z2`. + + z3: ArrayLikeObject + Third complex number view. + + sz3: integer + Stride length for `z3`. + + oz3: integer + Starting index for `z3`. + + z4: ArrayLikeObject + Third complex number view. + + sz4: integer + Stride length for `z4`. + + oz4: integer + Starting index for `z4`. + + out: ArrayLikeObject + Output array. + + so: integer + Stride length for `out`. + + oo: integer + Starting index for `out`. + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples + -------- + > var z1 = new {{alias:@stdlib/array/float64}}( [ 5.0, 3.0 ] ); + > var z2 = new {{alias:@stdlib/array/float64}}( [ 5.0, 3.0 ] ); + > var z3 = new {{alias:@stdlib/array/float64}}( [ 5.0, 3.0 ] ); + > var z4 = new {{alias:@stdlib/array/float64}}( [ 5.0, 3.0 ] ); + > var out = new {{alias:@stdlib/array/float64}}( 2 ); + > {{alias}}.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ) + [ 20.0, 12.0 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/docs/types/index.d.ts b/lib/node_modules/@stdlib/complex/float64/base/add4/docs/types/index.d.ts new file mode 100644 index 000000000000..3021f0b57122 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/docs/types/index.d.ts @@ -0,0 +1,154 @@ +/* +* @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 { Complex128 } from '@stdlib/types/complex'; +import { Collection, NumericArray } from '@stdlib/types/array'; + +/** +* Interface for summing four double-precision complex floating-point numbers. +*/ +interface Add { + /** + * Computes the sum of four double-precision complex floating-point numbers. + * + * @param z1 - first complex number + * @param z2 - second complex number + * @param z3 - third complex number + * @param z4 - fourth complex number + * @returns result + * + * @example + * var Complex128 = require( '@stdlib/complex/float64/ctor' ); + * + * var z = new Complex128( 5.0, 3.0 ); + * + * var out = add( z, z, z, z ); + * // returns [ 20.0, 12.0 ] + */ + ( z1: Complex128, z2: Complex128, z3: Complex128, z4: Complex128 ): Complex128; + + /** + * Computes the sum of four double-precision complex floating-point numbers and assigns results to a provided output array. + * + * @param re1 - real component of the first complex number + * @param im1 - imaginary component of the first complex number + * @param re2 - real component of the second complex number + * @param im2 - imaginary component of the second complex number + * @param re3 - real component of the third complex number + * @param im3 - imaginary component of the third complex number + * @param re4 - real component of the fourth complex number + * @param im4 - imaginary component of the fourth complex number + * @param out - output array + * @param strideOut - stride length + * @param offsetOut - starting index + * @returns output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var out = new Float64Array( 2 ); + * var v = add.assign( 5.0, 3.0, 5.0, 3.0, 5.0, 3.0, 5.0, 3.0, out, 1, 0 ); + * // returns [ 20.0, 12.0 ] + * + * var bool = ( out === v ); + * // returns true + */ + assign>( re1: number, im1: number, re2: number, im2: number, re3: number, im3: number, re4: number, im4: number, out: T, strideOut: number, offsetOut: number ): T; + + /** + * Computes the sum of four double-precision complex floating-point numbers stored in real-valued strided array views and assigns results to a provided strided output array. + * + * @param z1 - first complex number view + * @param strideZ1 - stride length for `z1` + * @param offsetZ1 - starting index for `z1` + * @param z2 - second complex number view + * @param strideZ2 - stride length for `z2` + * @param offsetZ2 - starting index for `z2` + * @param z3 - third complex number view + * @param strideZ3 - stride length for `z3` + * @param offsetZ3 - starting index for `z3` + * @param z4 - fourth complex number view + * @param strideZ4 - stride length for `z4` + * @param offsetZ4 - starting index for `z4` + * @param out - output array + * @param strideOut - stride length for `out` + * @param offsetOut - starting index for `out` + * @returns output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var z1 = new Float64Array( [ 5.0, 3.0 ] ); + * var z2 = new Float64Array( [ 5.0, 3.0 ] ); + * var z3 = new Float64Array( [ 5.0, 3.0 ] ); + * var z4 = new Float64Array( [ 5.0, 3.0 ] ); + * + * var out = add.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, new Float64Array( 2 ), 1, 0 ); + * // returns [ 20.0, 12.0 ] + */ + strided, U extends NumericArray | Collection, V extends NumericArray | Collection, W extends NumericArray | Collection, X extends NumericArray | Collection>( z1: T, strideZ1: number, offsetZ1: number, z2: U, strideZ2: number, offsetZ2: number, z3: V, strideZ3: number, offsetZ3: number, z4: W, strideZ4: number, offsetZ4: number, out: X, strideOut: number, offsetOut: number ): X; +} + +/** +* Computes the sum of four double-precision complex floating-point numbers. +* +* @param z1 - first complex number +* @param z2 - second complex number +* @param z3 - third complex number +* @param z4 - fourth complex number +* @returns result +* +* @example +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* +* var z = new Complex128( 5.0, 3.0 ); +* +* var out = add( z, z, z, z ); +* // returns [ 20.0, 12.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var out = new Float64Array( 2 ); +* var v = add.assign( 5.0, 3.0, 5.0, 3.0, 5.0, 3.0, 5.0, 3.0, out, 1, 0 ); +* // returns [ 20.0, 12.0 ] +* +* var bool = ( out === v ); +* // returns true +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var z1 = new Float64Array( [ 5.0, 3.0 ] ); +* var z2 = new Float64Array( [ 5.0, 3.0 ] ); +* var z3 = new Float64Array( [ 5.0, 3.0 ] ); +* var z4 = new Float64Array( [ 5.0, 3.0 ] ); +* +* var out = add.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, new Float64Array( 2 ), 1, 0 ); +* // returns [ 20.0, 12.0 ] +*/ +declare var add: Add; + + +// EXPORTS // + +export = add; diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/docs/types/test.ts b/lib/node_modules/@stdlib/complex/float64/base/add4/docs/types/test.ts new file mode 100644 index 000000000000..4b0a0708c81d --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/docs/types/test.ts @@ -0,0 +1,583 @@ +/* +* @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 Complex128 = require( '@stdlib/complex/float64/ctor' ); +import add4 = require( './index' ); + + +// TESTS // + +// The function returns a complex number... +{ + const z = new Complex128( 1.0, 1.0 ); + + add4( z, z, z, z ); // $ExpectType Complex128 +} + +// The compiler throws an error if the function is provided a first argument which is not a complex number... +{ + const z = new Complex128( 1.0, 1.0 ); + + add4( true, z, z, z ); // $ExpectError + add4( false, z, z, z ); // $ExpectError + add4( null, z, z, z ); // $ExpectError + add4( undefined, z, z, z ); // $ExpectError + add4( '5', z, z, z ); // $ExpectError + add4( [], z, z, z ); // $ExpectError + add4( {}, z, z, z ); // $ExpectError + add4( ( x: number ): number => x, z, z, z ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a complex number... +{ + const z = new Complex128( 1.0, 1.0 ); + + add4( z, true, z, z ); // $ExpectError + add4( z, false, z, z ); // $ExpectError + add4( z, null, z, z ); // $ExpectError + add4( z, undefined, z, z ); // $ExpectError + add4( z, '5', z, z ); // $ExpectError + add4( z, [], z, z ); // $ExpectError + add4( z, {}, z, z ); // $ExpectError + add4( z, ( x: number ): number => x, z, z ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a complex number... +{ + const z = new Complex128( 1.0, 1.0 ); + + add4( z, z, z, true ); // $ExpectError + add4( z, z, z, false ); // $ExpectError + add4( z, z, z, null ); // $ExpectError + add4( z, z, z, undefined ); // $ExpectError + add4( z, z, z, '5' ); // $ExpectError + add4( z, z, z, [] ); // $ExpectError + add4( z, z, z, {} ); // $ExpectError + add4( z, z, z, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a complex number... +{ + const z = new Complex128( 1.0, 1.0 ); + + add4( z, z, z, z, true ); // $ExpectError + add4( z, z, z, z, false ); // $ExpectError + add4( z, z, z, z, null ); // $ExpectError + add4( z, z, z, z, undefined ); // $ExpectError + add4( z, z, z, z, '5' ); // $ExpectError + add4( z, z, z, z, [] ); // $ExpectError + add4( z, z, z, z, {} ); // $ExpectError + add4( z, z, z, z, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const z = new Complex128( 1.0, 1.0 ); + + add4(); // $ExpectError + add4( z ); // $ExpectError + add4( z, z ); // $ExpectError + add4( z, z, z, z ); // $ExpectError + add4( z, z, z, z, z ); // $ExpectError +} + +// Attached to the main export is an `assign` method which returns a collection... +{ + add4.assign( 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, new Float64Array( 2 ), 1, 0 ); // $ExpectType Float64Array + add4.assign( 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, new Float32Array( 2 ), 1, 0 ); // $ExpectType Float32Array + add4.assign( 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, [ 0.0, 0.0 ], 1, 0 ); // $ExpectType number[] +} + +// The compiler throws an error if the `assign` method is provided a first argument which is not a number... +{ + const out = new Float64Array( 2 ); + + add4.assign( true, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( false, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( null, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( undefined, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( '5', 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( [], 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( {}, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( ( x: number ): number => x, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a second argument which is not a number... +{ + const out = new Float64Array( 2 ); + + add4.assign( 1.0, true, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, false, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, null, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, undefined, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, '5', 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, [], 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, {}, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, ( x: number ): number => x, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a third argument which is not a number... +{ + const out = new Float64Array( 2 ); + + add4.assign( 1.0, 2.0, true, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, false, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, null, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, undefined, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, '5', 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, [], 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, {}, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, ( x: number ): number => x, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... +{ + const out = new Float64Array( 2 ); + + add4.assign( 1.0, 2.0, 3.0, true, 5.0, 6.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, false, 5.0, 6.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, null, 5.0, 6.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, undefined, 5.0, 6.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, '5', 5.0, 6.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, [], 5.0, 6.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, {}, 5.0, 6.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, ( x: number ): number => x, 5.0, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... +{ + const out = new Float64Array( 2 ); + + add4.assign( 1.0, 2.0, 3.0, 4.0, true, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, false, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, null, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, undefined, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, '5', 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, [], 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, {}, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, ( x: number ): number => x, 6.0, 7.0, 8.0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... +{ + const out = new Float64Array( 2 ); + + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, true, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, false, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, null, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, undefined, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, '5', 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, [], 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, {}, 7.0, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, ( x: number ): number => x, 7.0, 8.0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a seventh argument which is not a number... +{ + const out = new Float64Array( 2 ); + + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, true, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, false, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, null, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, undefined, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, '5', 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, [], 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, {}, 8.0, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, ( x: number ): number => x, 8.0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a eighth argument which is not a collection... +{ + const out = new Float64Array( 2 ); + + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, true, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, false, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, null, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, undefined, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, '5', out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, [], out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, {}, out, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, ( x: number ): number => x, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a ninth argument which is not a number... +{ + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 1, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, true, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, false, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, null, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, undefined, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, '5', 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, [ '5' ], 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, {}, 1, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a tenth argument which is not a number... +{ + const out = new Float64Array( 2 ); + + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, true, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, false, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, null, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, undefined, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, '5', 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, [], 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, {}, 0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a eleventh argument which is not a number... +{ + const out = new Float64Array( 2 ); + + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, true ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, false ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, null ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, undefined ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, '5' ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, [] ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, {} ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... +{ + const out = new Float64Array( 2 ); + + add4.assign(); // $ExpectError + add4.assign( 1.0 ); // $ExpectError + add4.assign( 1.0, 2.0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1 ); // $ExpectError + add4.assign( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, out, 1, 0, {} ); // $ExpectError +} + +// Attached to the main export is a `strided` method which returns a collection... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z1.length ); + const z4 = new Float64Array( z1.length ); + + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, new Float64Array( 2 ), 1, 0 ); // $ExpectType Float64Array + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, new Float32Array( 2 ), 1, 0 ); // $ExpectType Float32Array + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, [ 0.0, 0.0 ], 1, 0 ); // $ExpectType number[] +} + +// The compiler throws an error if the `strided` method is provided a first argument which is not a collection... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z1.length ); + const z4 = new Float64Array( z1.length ); + const out = new Float64Array( z1.length ); + + add4.strided( true, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( false, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( null, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( undefined, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( '5', 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( [ '5' ], 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( {}, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( ( x: number ): number => x, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a second argument which is not a number... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z1.length ); + const z4 = new Float64Array( z1.length ); + const out = new Float64Array( z1.length ); + + add4.strided( z1, true, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, false, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, null, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, undefined, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, '5', 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, [], 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, {}, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, ( x: number ): number => x, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a third argument which is not a number... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z1.length ); + const z4 = new Float64Array( z1.length ); + const out = new Float64Array( 2 ); + + add4.strided( z1, 1, true, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, false, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, null, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, undefined, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, '5', z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, [], z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, {}, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, ( x: number ): number => x, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a fourth argument which is not a collection... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z2.length ); + const z4 = new Float64Array( z1.length ); + const out = new Float64Array( z1.length ); + + add4.strided( z1, 1, 0, true, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, false, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, null, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, undefined, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, '5', 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, [ '5' ], 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, {}, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, ( x: number ): number => x, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a fifth argument which is not a number... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z1.length ); + const z4 = new Float64Array( z1.length ); + const out = new Float64Array( z1.length ); + + add4.strided( z1, 1, 0, z2, true, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, false, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, null, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, undefined, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, '5', 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, [], 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, {}, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, ( x: number ): number => x, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a sixth argument which is not a number... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z1.length ); + const z4 = new Float64Array( z1.length ); + const out = new Float64Array( z1.length ); + + add4.strided( z1, 1, 0, z2, 1, true, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, false, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, null, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, undefined, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, '5', z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, [], z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, {}, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, ( x: number ): number => x, z3, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a seventh argument which is not a collection... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z2.length ); + const z4 = new Float64Array( z1.length ); + const out = new Float64Array( z3.length ); + + add4.strided( z1, 1, 0, z3, 1, 0, true, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z3, 1, 0, false, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z3, 1, 0, null, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z3, 1, 0, undefined, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z3, 1, 0, '5', 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z3, 1, 0, [ '5' ], 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z3, 1, 0, {}, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z3, 1, 0, ( x: number ): number => x, 1, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided an eighth argument which is not a number... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z1.length ); + const z4 = new Float64Array( z1.length ); + const out = new Float64Array( z1.length ); + + add4.strided( z1, 1, 0, z2, 1, 0, z3, true, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, false, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, null, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, undefined, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, '5', 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, [], 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, {}, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, ( x: number ): number => x, 0, z4, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a ninth argument which is not a number... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z1.length ); + const z4 = new Float64Array( z1.length ); + const out = new Float64Array( z1.length ); + + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, true, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, false, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, null, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, undefined, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, '5', z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, [], z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, {}, z4, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, ( x: number ): number => x, z4, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a tenth argument which is not a collection... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z1.length ); + const z4 = new Float64Array( z1.length ); + const out = new Float64Array( z1.length ); + + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, true, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, false, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, null, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, undefined, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, '5', 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, [], 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, {}, 1, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, ( x: number ): number => x, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a eleventh argument which is not a collection... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z1.length ); + const z4 = new Float64Array( z1.length ); + const out = new Float64Array( z1.length ); + + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, true, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, false, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, null, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, undefined, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, '5', 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, [], 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, {}, 0, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, ( x: number ): number => x, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a twelfth argument which is not a collection... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z1.length ); + const z4 = new Float64Array( z1.length ); + const out = new Float64Array( z1.length ); + + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, true, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, false, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, null, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, undefined, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, '5', out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, [], out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, {}, out, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, ( x: number ): number => x, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided an thirteenth argument which is not a number... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z1.length ); + const z4 = new Float64Array( z1.length ); + const out = new Float64Array( z1.length ); + + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, 1, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, true, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, false, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, null, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, undefined, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, '5', 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, [], 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, {}, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a fourteenth argument which is not a number... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z1.length ); + const z4 = new Float64Array( z1.length ); + const out = new Float64Array( z1.length ); + + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, true, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, false, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, null, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, undefined, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, '5', 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, [], 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, {}, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a fifteenth argument which is not a number... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z1.length ); + const z4 = new Float64Array( z1.length ); + const out = new Float64Array( z1.length ); + + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, true ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, false ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, null ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, undefined ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, '5' ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, [] ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, {} ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided an unsupported number of arguments... +{ + const z1 = new Float64Array( 2 ); + const z2 = new Float64Array( z1.length ); + const z3 = new Float64Array( z1.length ); + const z4 = new Float64Array( z1.length ); + const out = new Float64Array( z1.length ); + + add4.strided(); // $ExpectError + add4.strided( z1 ); // $ExpectError + add4.strided( z1, 1 ); // $ExpectError + add4.strided( z1, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1 ); // $ExpectError + add4.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/examples/c/Makefile b/lib/node_modules/@stdlib/complex/float64/base/add4/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/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/complex/float64/base/add4/examples/c/example.c b/lib/node_modules/@stdlib/complex/float64/base/add4/examples/c/example.c new file mode 100644 index 000000000000..d7f319f85294 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/examples/c/example.c @@ -0,0 +1,46 @@ +/** +* @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/complex/float64/base/add4.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" +#include + +int main( void ) { + const stdlib_complex128_t x[] = { + stdlib_complex128( 3.14, 1.5 ), + stdlib_complex128( -3.14, 1.5 ), + stdlib_complex128( 0.0, -0.0 ), + stdlib_complex128( 0.0/0.0, 0.0/0.0 ) + }; + + stdlib_complex128_t v; + stdlib_complex128_t y; + double re; + double im; + int i; + for ( i = 0; i < 4; i++ ) { + v = x[ i ]; + stdlib_complex128_reim( v, &re, &im ); + printf( "z = %lf + %lfi\n", re, im ); + + y = stdlib_base_complex128_add3( v, v, v, v ); + stdlib_complex128_reim( y, &re, &im ); + printf( "add3(z, z, z, z) = %lf + %lfi\n", re, im ); + } +} diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/examples/index.js b/lib/node_modules/@stdlib/complex/float64/base/add4/examples/index.js new file mode 100644 index 000000000000..872f12c78233 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/examples/index.js @@ -0,0 +1,33 @@ +/** +* @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 Complex128Array = require( '@stdlib/array/complex128' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var add4 = require( './../lib' ); + +// Generate arrays of random values: +var z1 = new Complex128Array( discreteUniform( 200, -50, 50 ) ); +var z2 = new Complex128Array( discreteUniform( 200, -50, 50 ) ); +var z3 = new Complex128Array( discreteUniform( 200, -50, 50 ) ); +var z4 = new Complex128Array( discreteUniform( 200, -50, 50 ) ); + +// Perform element-wise addition: +logEachMap( '(%s) + (%s) + (%s) + (%s) = %s', z1, z2, z3, z4, add4 ); diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/include.gypi b/lib/node_modules/@stdlib/complex/float64/base/add4/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '[ 20.0, 12.0 ] +*/ +function assign( re1, im1, re2, im2, re3, im3, re4, im4, out, strideOut, offsetOut ) { + out[ offsetOut ] = re1 + re2 + re3 + re4; + out[ offsetOut+strideOut ] = im1 + im2 + im3 + im4; + return out; +} + + +// EXPORTS // + +module.exports = assign; diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/lib/index.js b/lib/node_modules/@stdlib/complex/float64/base/add4/lib/index.js new file mode 100644 index 000000000000..ad5b9fe43c23 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/lib/index.js @@ -0,0 +1,54 @@ +/** +* @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'; + +/** +* Compute the sum of four double-precision complex floating-point numbers. +* +* @module @stdlib/complex/float64/base/add4 +* +* @example +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* var add4 = require( '@stdlib/complex/float64/base/add4' ); +* +* var z = new Complex128( 5.0, 3.0 ); +* +* var out = add4( z, z, z, z ); +* // returns [ 20.0, 12.0 ] +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var assign = require( './assign.js' ); +var strided = require( './strided.js' ); + + +// MAIN // + +setReadOnly( main, 'assign', assign ); +setReadOnly( main, 'strided', strided ); + + +// EXPORTS // + +module.exports = main; + +// exports: { "assign": "main.assign", "strided": "main.strided" } diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/lib/main.js b/lib/node_modules/@stdlib/complex/float64/base/add4/lib/main.js new file mode 100644 index 000000000000..92c03734343f --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/lib/main.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); + + +// MAIN // + +/** +* Computes the sum of four double-precision complex floating-point numbers. +* +* @param {Complex128} z1 - first complex number +* @param {Complex128} z2 - second complex number +* @param {Complex128} z3 - third complex number +* @param {Complex128} z4 - third complex number +* @returns {Complex128} result +* +* @example +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* +* var z = new Complex128( 5.0, 3.0 ); +* +* var out = add4( z, z, z, z ); +* // returns [ 20.0, 12.0 ] +*/ +function add4( z1, z2, z3, z4 ) { + var re = real( z1 ) + real( z2 ) + real( z3 ) + real( z4 ); + var im = imag( z1 ) + imag( z2 ) + imag( z3 ) + imag( z4 ); + return new Complex128( re, im ); +} + + +// EXPORTS // + +module.exports = add4; diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/lib/native.js b/lib/node_modules/@stdlib/complex/float64/base/add4/lib/native.js new file mode 100644 index 000000000000..9a366066155d --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/lib/native.js @@ -0,0 +1,55 @@ +/** +* @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 Complex128 = require( '@stdlib/complex/float64/ctor' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Computes the sum of four double-precision complex floating-point numbers. +* +* @private +* @param {Complex128} z1 - first complex number +* @param {Complex128} z2 - second complex number +* @param {Complex128} z3 - third complex number +* @param {Complex128} z4 - third complex number +* @returns {Complex128} result +* +* @example +* var Complex128 = require( '@stdlib/complex/float64/ctor' ); +* +* var z = new Complex128( 5.0, 3.0 ); +* +* var out = add4( z, z, z, z ); +* // returns [ 20.0, 12.0 ] +*/ +function add4( z1, z2, z3, z4 ) { + var v = addon( z1, z2, z3, z4 ); + return new Complex128( v.re, v.im ); +} + + +// EXPORTS // + +module.exports = add4; diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/lib/strided.js b/lib/node_modules/@stdlib/complex/float64/base/add4/lib/strided.js new file mode 100644 index 000000000000..db284dddaa8d --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/lib/strided.js @@ -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. +*/ + +'use strict'; + +// MAIN // + +/** +* Computes the sum of four double-precision complex floating-point numbers stored in real-valued strided array views and assigns results to a provided strided output array. +* +* @param {Float64Array} z1 - first complex number view +* @param {integer} strideZ1 - stride length for `z1` +* @param {NonNegativeInteger} offsetZ1 - starting index for `z1` +* @param {Float64Array} z2 - second complex number view +* @param {integer} strideZ2 - stride length for `z2` +* @param {NonNegativeInteger} offsetZ2 - starting index for `z2` +* @param {Float64Array} z3 - third complex number view +* @param {integer} strideZ3 - stride length for `z3` +* @param {NonNegativeInteger} offsetZ3 - starting index for `z3` +* @param {Float64Array} z4 - fourth complex number view +* @param {integer} strideZ4 - stride length for `z4` +* @param {NonNegativeInteger} offsetZ4 - starting index for `z4` +* @param {Collection} out - output array +* @param {integer} strideOut - stride length for `out` +* @param {NonNegativeInteger} offsetOut - starting index for `out` +* @returns {Collection} output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var z1 = new Float64Array( [ 5.0, 3.0 ] ); +* var z2 = new Float64Array( [ 5.0, 3.0 ] ); +* var z3 = new Float64Array( [ 5.0, 3.0 ] ); +* var z4 = new Float64Array( [ 5.0, 3.0 ] ); +* +* var out = strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, new Float64Array( 2 ), 1, 0 ); +* // returns [ 20.0, 12.0 ] +*/ +function strided( z1, strideZ1, offsetZ1, z2, strideZ2, offsetZ2, z3, strideZ3, offsetZ3, z4, strideZ4, offsetZ4, out, strideOut, offsetOut ) { // eslint-disable-line max-len, max-params + out[ offsetOut ] = z1[ offsetZ1 ] + z2[ offsetZ2 ] + z3[ offsetZ3 ] + z4[ offsetZ4 ]; + out[ offsetOut+strideOut ] = z1[ offsetZ1+strideZ1 ] + z2[ offsetZ2+strideZ2 ] + z3[ offsetZ3+strideZ3 ] + z4[ offsetZ4+strideZ4 ]; // eslint-disable-line max-len + return out; +} + + +// EXPORTS // + +module.exports = strided; diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/manifest.json b/lib/node_modules/@stdlib/complex/float64/base/add4/manifest.json new file mode 100644 index 000000000000..0921b6d7f374 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/manifest.json @@ -0,0 +1,75 @@ +{ + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/quaternary", + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/reim" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/reim" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/complex/float64/ctor", + "@stdlib/complex/float64/reim" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/package.json b/lib/node_modules/@stdlib/complex/float64/base/add4/package.json new file mode 100644 index 000000000000..c2ec7130aa37 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/complex/float64/base/add4", + "version": "0.0.0", + "description": "Compute the sum of four double-precision complex floating-point numbers.", + "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", + "cadd", + "add", + "addition", + "sum", + "arithmetic", + "complex", + "cmplx", + "number" + ] +} diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/src/Makefile b/lib/node_modules/@stdlib/complex/float64/base/add4/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/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/complex/float64/base/add4/src/addon.c b/lib/node_modules/@stdlib/complex/float64/base/add4/src/addon.c new file mode 100644 index 000000000000..c72eeb87247e --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/src/addon.c @@ -0,0 +1,22 @@ +/** +* @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/complex/float64/base/add4.h" +#include "stdlib/math/base/napi/quaternary.h" + +STDLIB_MATH_BASE_NAPI_MODULE_ZZZZ_Z( stdlib_base_complex128_add4 ) diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/src/main.c b/lib/node_modules/@stdlib/complex/float64/base/add4/src/main.c new file mode 100644 index 000000000000..bb97457872ed --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/src/main.c @@ -0,0 +1,68 @@ +/** +* @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/complex/float64/base/add4.h" +#include "stdlib/complex/float64/ctor.h" +#include "stdlib/complex/float64/reim.h" + +/** +* Computes the sum of four double-precision complex floating-point numbers. +* +* @param z1 first input value +* @param z2 second input value +* @param z3 third input value +* @param z4 four input value +* @return result +* +* @example +* #include "stdlib/complex/float64/ctor.h" +* #include "stdlib/complex/float64/real.h" +* #include "stdlib/complex/float64/imag.h" +* +* stdlib_complex128_t z = stdlib_complex128( 3.0, -2.0 ); +* +* stdlib_complex128_t out = stdlib_base_complex128_add4( z, z, z, z ); +* +* double re = stdlib_complex128_real( out ); +* // returns 12.0 +* +* double im = stdlib_complex128_imag( out ); +* // returns -8.0 +*/ +stdlib_complex128_t stdlib_base_complex128_add4( const stdlib_complex128_t z1, const stdlib_complex128_t z2, const stdlib_complex128_t z3,const stdlib_complex128_t z4 ) { + double re1; + double im1; + double re2; + double im2; + double re3; + double im3; + double re4; + double im4; + double re; + double im; + + stdlib_complex128_reim( z1, &re1, &im1 ); + stdlib_complex128_reim( z2, &re2, &im2 ); + stdlib_complex128_reim( z3, &re3, &im3 ); + stdlib_complex128_reim( z4, &re4, &im4 ); + + re = re1 + re2 + re3 + re4; + im = im1 + im2 + im3 + im4; + + return stdlib_complex128( re, im ); +} diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/test/test.assign.js b/lib/node_modules/@stdlib/complex/float64/base/add4/test/test.assign.js new file mode 100644 index 000000000000..9f2b1f2fc927 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/test/test.assign.js @@ -0,0 +1,132 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Float64Array = require( '@stdlib/array/float64' ); +var assign = require( './../lib/assign.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof assign, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function sums three complex numbers', function test( t ) { + var expected; + var out; + var v; + + out = new Float64Array( 2 ); + v = assign( 5.0, 3.0, -2.0, 1.0, -5.0, -3.0, 1.0, -4.0, out, 1, 0 ); + + expected = new Float64Array( [ -1.0, -3.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + out = new Float64Array( 4 ); + v = assign( 5.0, 3.0, -2.0, 1.0, -5.0, -3.0, 1.0, -4.0, out, 2, 0 ); + + expected = new Float64Array( [ -1.0, 0.0, -3.0, 0.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + out = new Float64Array( 4 ); + v = assign( 5.0, 3.0, -2.0, 1.0, -5.0, -3.0, 1.0, -4.0, out, 2, 1 ); + + expected = new Float64Array( [ 0.0, -1.0, 0.0, -3.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + out = new Float64Array( 4 ); + v = assign( 5.0, 3.0, -2.0, 1.0, -5.0, -3.0, 1.0, -4.0, out, -2, 3 ); + + expected = new Float64Array( [ 0.0, -3.0, 0.0, -1.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if a real or imaginary component is `NaN`, the output component is `NaN`', function test( t ) { + var expected; + var out; + var v; + + out = new Float64Array( 2 ); + expected = new Float64Array( [ NaN, 1.0 ] ); + + v = assign( NaN, 3.0, -2.0, 1.0, -5.0, -3.0, 1.0, 0.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + expected = new Float64Array( [ NaN, 1.0 ] ); + + v = assign( 5.0, 3.0, NaN, 1.0, -5.0, -3.0, 1.0, 0.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + expected = new Float64Array( [ NaN, 1.0 ] ); + + v = assign( NaN, 3.0, NaN, 1.0, NaN, -3.0, NaN, 0.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + expected = new Float64Array( [ -1.0, NaN ] ); + + v = assign( 5.0, NaN, -2.0, 1.0, -5.0, -3.0, 1.0, 1.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + expected = new Float64Array( [ -1.0, NaN ] ); + + v = assign( 5.0, 3.0, -2.0, NaN, -5.0, -3.0, 1.0, 1.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + expected = new Float64Array( [ -1.0, NaN ] ); + + v = assign( 5.0, NaN, -2.0, NaN, -5.0, NaN, 1.0, NaN, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + expected = new Float64Array( [ NaN, NaN ] ); + + v = assign( NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/test/test.js b/lib/node_modules/@stdlib/complex/float64/base/add4/test/test.js new file mode 100644 index 000000000000..5fafbfd6cf29 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/test/test.js @@ -0,0 +1,46 @@ +/** +* @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 isMethod = require( '@stdlib/assert/is-method' ); +var add4 = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof add4, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( isMethod( add4, 'assign' ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is a `strided` method', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( isMethod( add4, 'strided' ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/test/test.main.js b/lib/node_modules/@stdlib/complex/float64/base/add4/test/test.main.js new file mode 100644 index 000000000000..0e0d4945470f --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/test/test.main.js @@ -0,0 +1,130 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var add4 = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof add4, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function sums three complex numbers', function test( t ) { + var z1; + var z2; + var z3; + var z4; + var v; + + z1 = new Complex128( 5.0, 3.0 ); + z2 = new Complex128( -2.0, 1.0 ); + z3 = new Complex128( -5.0, -3.0 ); + z4 = new Complex128( 1.0, -4.0 ); + + v = add4( z1, z2, z3, z4 ); + + t.strictEqual( real( v ), -1.0, 'returns expected value' ); + t.strictEqual( imag( v ), -3.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'if a real or imaginary component is `NaN`, the resulting component is `NaN`', function test( t ) { + var z1; + var z2; + var z3; + var z4; + var v; + + z1 = new Complex128( NaN, 3.0 ); + z2 = new Complex128( -2.0, 1.0 ); + z3 = new Complex128( -5.0, -3.0 ); + z4 = new Complex128( 1.0, -4.0 ); + + v = add4( z1, z2, z3, z4 ); + t.strictEqual( isnan( real( v ) ), true, 'returns expected value' ); + t.strictEqual( imag( v ), -3.0, 'returns expected value' ); + + z1 = new Complex128( 5.0, 3.0 ); + z2 = new Complex128( NaN, 1.0 ); + z3 = new Complex128( -5.0, -3.0 ); + z4 = new Complex128( 1.0, -4.0 ); + + v = add4( z1, z2, z3, z4 ); + t.strictEqual( isnan( real( v ) ), true, 'returns expected value' ); + t.strictEqual( imag( v ), -3.0, 'returns expected value' ); + + z1 = new Complex128( NaN, 3.0 ); + z2 = new Complex128( NaN, 1.0 ); + z3 = new Complex128( NaN, -3.0 ); + z4 = new Complex128( NaN, -4.0 ); + + v = add4( z1, z2, z3, z4 ); + t.strictEqual( isnan( real( v ) ), true, 'returns expected value' ); + t.strictEqual( imag( v ), -3.0, 'returns expected value' ); + + z1 = new Complex128( 5.0, NaN ); + z2 = new Complex128( -2.0, 1.0 ); + z3 = new Complex128( -5.0, -3.0 ); + z4 = new Complex128( 1.0, -4.0 ); + + v = add4( z1, z2, z3, z4 ); + t.strictEqual( real( v ), -1.0, 'returns expected value' ); + t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' ); + + z1 = new Complex128( 5.0, 3.0 ); + z2 = new Complex128( -2.0, NaN ); + z3 = new Complex128( -5.0, -3.0 ); + z4 = new Complex128( 1.0, -4.0 ); + + v = add4( z1, z2, z3, z4 ); + t.strictEqual( real( v ), -1.0, 'returns expected value' ); + t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' ); + + z1 = new Complex128( 5.0, NaN ); + z2 = new Complex128( -2.0, NaN ); + z3 = new Complex128( -5.0, NaN ); + z4 = new Complex128( 1.0, NaN ); + + v = add4( z1, z2, z3, z4 ); + t.strictEqual( real( v ), -1.0, 'returns expected value' ); + t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' ); + + z1 = new Complex128( NaN, NaN ); + z2 = new Complex128( NaN, NaN ); + z3 = new Complex128( NaN, NaN ); + z4 = new Complex128( NaN, NaN ); + + v = add4( z1, z2, z3, z4 ); + t.strictEqual( isnan( real( v ) ), true, 'returns expected value' ); + t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/test/test.native.js b/lib/node_modules/@stdlib/complex/float64/base/add4/test/test.native.js new file mode 100644 index 000000000000..a9759a9c412c --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/test/test.native.js @@ -0,0 +1,139 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Complex128 = require( '@stdlib/complex/float64/ctor' ); +var real = require( '@stdlib/complex/float64/real' ); +var imag = require( '@stdlib/complex/float64/imag' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var add4 = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( add4 instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof add4, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function sums three complex numbers', opts, function test( t ) { + var z1; + var z2; + var z3; + var z4; + var v; + + z1 = new Complex128( 5.0, 3.0 ); + z2 = new Complex128( -2.0, 1.0 ); + z3 = new Complex128( -5.0, -3.0 ); + z4 = new Complex128( 1.0, -4.0 ); + + v = add4( z1, z2, z3, z4 ); + + t.strictEqual( real( v ), -1.0, 'returns expected value' ); + t.strictEqual( imag( v ), -3.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'if a real or imaginary component is `NaN`, the resulting component is `NaN`', opts, function test( t ) { + var z1; + var z2; + var z3; + var z4; + var v; + + z1 = new Complex128( NaN, 3.0 ); + z2 = new Complex128( -2.0, 1.0 ); + z3 = new Complex128( -5.0, -3.0 ); + z4 = new Complex128( 1.0, -4.0 ); + + v = add4( z1, z2, z3, z4 ); + t.strictEqual( isnan( real( v ) ), true, 'returns expected value' ); + t.strictEqual( imag( v ), -3.0, 'returns expected value' ); + + z1 = new Complex128( 5.0, 3.0 ); + z2 = new Complex128( NaN, 1.0 ); + z3 = new Complex128( -5.0, -3.0 ); + z4 = new Complex128( 1.0, -4.0 ); + + v = add4( z1, z2, z3, z4 ); + t.strictEqual( isnan( real( v ) ), true, 'returns expected value' ); + t.strictEqual( imag( v ), -3.0, 'returns expected value' ); + + z1 = new Complex128( NaN, 3.0 ); + z2 = new Complex128( NaN, 1.0 ); + z3 = new Complex128( NaN, -3.0 ); + z4 = new Complex128( NaN, -4.0 ); + + v = add4( z1, z2, z3, z4 ); + t.strictEqual( isnan( real( v ) ), true, 'returns expected value' ); + t.strictEqual( imag( v ), -3.0, 'returns expected value' ); + + z1 = new Complex128( 5.0, NaN ); + z2 = new Complex128( -2.0, 1.0 ); + z3 = new Complex128( -5.0, -3.0 ); + z4 = new Complex128( 1.0, -4.0 ); + + v = add4( z1, z2, z3, z4 ); + t.strictEqual( real( v ), -1.0, 'returns expected value' ); + t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' ); + + z1 = new Complex128( 5.0, 3.0 ); + z2 = new Complex128( -2.0, NaN ); + z3 = new Complex128( -5.0, -3.0 ); + z4 = new Complex128( 1.0, -4.0 ); + + v = add4( z1, z2, z3, z4 ); + t.strictEqual( real( v ), -1.0, 'returns expected value' ); + t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' ); + + z1 = new Complex128( 5.0, NaN ); + z2 = new Complex128( -2.0, NaN ); + z3 = new Complex128( -5.0, NaN ); + z4 = new Complex128( 1.0, NaN ); + + v = add4( z1, z2, z3, z4 ); + t.strictEqual( real( v ), -1.0, 'returns expected value' ); + t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' ); + + z1 = new Complex128( NaN, NaN ); + z2 = new Complex128( NaN, NaN ); + z3 = new Complex128( NaN, NaN ); + z4 = new Complex128( NaN, NaN ); + + v = add4( z1, z2, z3, z4 ); + t.strictEqual( isnan( real( v ) ), true, 'returns expected value' ); + t.strictEqual( isnan( imag( v ) ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/complex/float64/base/add4/test/test.strided.js b/lib/node_modules/@stdlib/complex/float64/base/add4/test/test.strided.js new file mode 100644 index 000000000000..73e7697b94cf --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float64/base/add4/test/test.strided.js @@ -0,0 +1,184 @@ +/** +* @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 isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Float64Array = require( '@stdlib/array/float64' ); +var strided = require( './../lib/strided.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof strided, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function sums four complex numbers', function test( t ) { + var expected; + var out; + var z1; + var z2; + var z3; + var z4; + var v; + + z1 = new Float64Array( [ 5.0, 3.0 ] ); + z2 = new Float64Array( [ -2.0, 1.0 ] ); + z3 = new Float64Array( [ -5.0, -3.0 ] ); + z4 = new Float64Array( [ 1.0, -4.0 ] ); + out = new Float64Array( 2 ); + v = strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); + + expected = new Float64Array( [ -1.0, -3.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + z1 = new Float64Array( [ 5.0, 0.0, 3.0, 0.0 ] ); + z2 = new Float64Array( [ -2.0, 1.0 ] ); + z3 = new Float64Array( [ -5.0, -3.0 ] ); + z4 = new Float64Array( [ 1.0, -4.0 ] ); + out = new Float64Array( 4 ); + v = strided( z1, 2, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 2, 0 ); + + expected = new Float64Array( [ -1.0, 0.0, -3.0, 0.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + z1 = new Float64Array( [ 5.0, 3.0 ] ); + z2 = new Float64Array( [ 0.0, -2.0, 0.0, 1.0 ] ); + z3 = new Float64Array( [ -5.0, -3.0 ] ); + z4 = new Float64Array( [ 1.0, -4.0 ] ); + out = new Float64Array( 4 ); + v = strided( z1, 1, 0, z2, 2, 1, z3, 1, 0, z4, 1, 0, out, 2, 1 ); + + expected = new Float64Array( [ 0.0, -1.0, 0.0, -3.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + z1 = new Float64Array( [ 3.0, 5.0 ] ); + z2 = new Float64Array( [ 1.0, -2.0 ] ); + z3 = new Float64Array( [ -3.0, -5.0 ] ); + z4 = new Float64Array( [ 1.0, -4.0 ] ); + out = new Float64Array( 4 ); + v = strided( z1, -1, 1, z2, -1, 1, z3, -1, 1, z4, -1, 1, out, -2, 3 ); + + expected = new Float64Array( [ 0.0, 2.0, 0.0, -6.0 ] ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if a real or imaginary component is `NaN`, the output component is `NaN`', function test( t ) { + var expected; + var out; + var z1; + var z2; + var z3; + var z4; + var v; + + z1 = new Float64Array( [ NaN, 3.0 ] ); + z2 = new Float64Array( [ -2.0, 1.0 ] ); + z3 = new Float64Array( [ -5.0, -3.0 ] ); + z4 = new Float64Array( [ 1.0, -4.0 ] ); + out = new Float64Array( 2 ); + expected = new Float64Array( [ NaN, -3.0 ] ); + + v = strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + z1 = new Float64Array( [ 5.0, 3.0 ] ); + z2 = new Float64Array( [ NaN, 1.0 ] ); + z3 = new Float64Array( [ -5.0, -3.0 ] ); + z4 = new Float64Array( [ 1.0, -4.0 ] ); + out = new Float64Array( 2 ); + expected = new Float64Array( [ NaN, -3.0 ] ); + + v = strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + z1 = new Float64Array( [ NaN, 3.0 ] ); + z2 = new Float64Array( [ NaN, 1.0 ] ); + z3 = new Float64Array( [ NaN, -3.0 ] ); + z4 = new Float64Array( [ NaN, -4.0 ] ); + out = new Float64Array( 2 ); + expected = new Float64Array( [ NaN, -3.0 ] ); + + v = strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + z1 = new Float64Array( [ 5.0, NaN ] ); + z2 = new Float64Array( [ -2.0, 1.0 ] ); + z3 = new Float64Array( [ -5.0, -3.0 ] ); + z4 = new Float64Array( [ 1.0, -4.0 ] ); + out = new Float64Array( 2 ); + expected = new Float64Array( [ -1.0, NaN ] ); + + v = strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + z1 = new Float64Array( [ 5.0, 3.0 ] ); + z2 = new Float64Array( [ -2.0, NaN ] ); + z3 = new Float64Array( [ -5.0, -3.0 ] ); + z4 = new Float64Array( [ 1.0, -4.0 ] ); + out = new Float64Array( 2 ); + expected = new Float64Array( [ -1.0, NaN ] ); + + v = strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + z1 = new Float64Array( [ 5.0, NaN ] ); + z2 = new Float64Array( [ -2.0, NaN ] ); + z3 = new Float64Array( [ -5.0, NaN ] ); + z4 = new Float64Array( [ 1.0, NaN ] ); + out = new Float64Array( 2 ); + expected = new Float64Array( [ -1.0, NaN ] ); + + v = strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + z1 = new Float64Array( [ NaN, NaN ] ); + z2 = new Float64Array( [ NaN, NaN ] ); + z3 = new Float64Array( [ NaN, NaN ] ); + z4 = new Float64Array( [ NaN, NaN ] ); + out = new Float64Array( 2 ); + expected = new Float64Array( [ NaN, NaN ] ); + + v = strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, z4, 1, 0, out, 1, 0 ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' ); + + t.end(); +});