From 53ff701453daab8775e560a20384b37522e48c54 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 25 May 2024 15:54:30 -0700 Subject: [PATCH] feat: add `complex/float32/base/assert/is-equal` Ref: https://github.com/stdlib-js/stdlib/issues/2260 --- .../float32/base/assert/is-equal/README.md | 221 ++++++++++++++++++ .../assert/is-equal/benchmark/benchmark.js | 63 +++++ .../base/assert/is-equal/docs/repl.txt | 27 +++ .../assert/is-equal/docs/types/index.d.ts | 44 ++++ .../base/assert/is-equal/docs/types/test.ts | 67 ++++++ .../base/assert/is-equal/examples/c/Makefile | 146 ++++++++++++ .../base/assert/is-equal/examples/c/example.c | 38 +++ .../base/assert/is-equal/examples/index.js | 37 +++ .../complex/float32/base/assert/is_equal.h | 41 ++++ .../float32/base/assert/is-equal/lib/index.js | 44 ++++ .../float32/base/assert/is-equal/lib/main.js | 56 +++++ .../base/assert/is-equal/manifest.json | 59 +++++ .../float32/base/assert/is-equal/package.json | 71 ++++++ .../float32/base/assert/is-equal/src/main.c | 48 ++++ .../float32/base/assert/is-equal/test/test.js | 134 +++++++++++ 15 files changed, 1096 insertions(+) create mode 100644 lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/README.md create mode 100644 lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/examples/index.js create mode 100644 lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/include/stdlib/complex/float32/base/assert/is_equal.h create mode 100644 lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/lib/index.js create mode 100644 lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/lib/main.js create mode 100644 lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/manifest.json create mode 100644 lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/package.json create mode 100644 lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/src/main.c create mode 100644 lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/test/test.js diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/README.md b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/README.md new file mode 100644 index 00000000000..fbe6615c800 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/README.md @@ -0,0 +1,221 @@ + + +# isEqualf + +> Test whether two single-precision complex floating-point numbers are equal. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var isEqualf = require( '@stdlib/complex/float32/base/assert/is-equal' ); +``` + +#### isEqualf( z1, z2 ) + +Tests whether two single-precision complex floating-point numbers are equal. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); + +var z1 = new Complex64( 5.0, 3.0 ); +var z2 = new Complex64( 5.0, 3.0 ); + +var out = isEqualf( z1, z2 ); +// returns true +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var isEqualf = require( '@stdlib/complex/float32/base/assert/is-equal' ); + +var z1 = new Complex64( 5.0, 3.0 ); +var z2 = new Complex64( 5.0, 3.0 ); +var out = isEqualf( z1, z2 ); +// returns true + +z1 = new Complex64( -5.0, -3.0 ); +z2 = new Complex64( 5.0, 3.0 ); +out = isEqualf( z1, z2 ); +// returns false + +z1 = new Complex64( NaN, 3.0 ); +z2 = new Complex64( NaN, 3.0 ); +out = isEqualf( z1, z2 ); +// returns false +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/complex/float32/base/assert/is_equal.h" +``` + +#### stdlib_base_complex64_is_equal( z1, z2 ) + +Tests whether single-precision complex floating-point numbers are equal. + +```c +#include "stdlib/complex/float32/ctor.h" +#include + +stdlib_complex64_t z1 = stdlib_complex64( 5.0, 2.0 ); +stdlib_complex64_t z2 = stdlib_complex64( 5.0, 2.0 ); + +bool v = stdlib_base_complex64_is_equal( z1, z2 ); +``` + +The function accepts the following arguments: + +- **z1**: `[in] stdlib_complex64_t` first single-precision complex floating-point number. +- **z2**: `[in] stdlib_complex64_t` second single-precision complex floating-point number. + +```c +bool stdlib_base_complex64_is_equal( const stdlib_complex64_t z1, const stdlib_complex64_t z2 ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/complex/float32/base/assert/is_equal.h" +#include "stdlib/complex/float32/ctor.h" +#include +#include + +int main( void ) { + const stdlib_complex64_t z[] = { + stdlib_complex64( 5.0f, 2.0f ), + stdlib_complex64( -2.0f, 1.0f ), + stdlib_complex64( 0.0f, -0.0f ), + stdlib_complex64( 0.0f/0.0f, 0.0f/0.0f ) + }; + + bool v; + int i; + for ( i = 0; i < 4; i++ ) { + v = stdlib_base_complex64_is_equal( z[ i ], z[ i ] ); + printf( "Equal? %s\n", ( v ) ? "True" : "False" ); + } +} +``` + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/benchmark/benchmark.js b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/benchmark/benchmark.js new file mode 100644 index 00000000000..a5e24b2d2ba --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/benchmark/benchmark.js @@ -0,0 +1,63 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 Complex64 = require( '@stdlib/complex/float32/ctor' ); +var randu = require( '@stdlib/random/base/randu' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var isEqualf = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var z1; + var z2; + var v; + var i; + + z1 = [ + new Complex64( randu(), randu() ), + new Complex64( randu(), randu() ) + ]; + z2 = [ + new Complex64( randu(), randu() ), + new Complex64( randu(), randu() ), + z1[ 0 ], + z1[ 1 ] + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = isEqualf( z1[ i%z1.length ], z2[ i%z2.length ] ); + if ( typeof v !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( v ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/docs/repl.txt b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/docs/repl.txt new file mode 100644 index 00000000000..58fb14d3cbb --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/docs/repl.txt @@ -0,0 +1,27 @@ + +{{alias}}( z1, z2 ) + Tests whether two single-precision complex floating-point numbers are equal. + + Parameters + ---------- + z1: Complex64 + First complex number. + + z2: Complex64 + Second complex number. + + Returns + ------- + out: boolean + Result. + + Examples + -------- + > var z1 = new {{alias:@stdlib/complex/float32/ctor}}( 5.0, 3.0 ); + > var z2 = new {{alias:@stdlib/complex/float32/ctor}}( 5.0, 3.0 ); + > var v = {{alias}}( z1, z2 ) + true + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/docs/types/index.d.ts b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/docs/types/index.d.ts new file mode 100644 index 00000000000..21ce03a943f --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/docs/types/index.d.ts @@ -0,0 +1,44 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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 Complex64 = require( '@stdlib/complex/float32/ctor' ); + +/** +* Tests whether two single-precision complex floating-point numbers are equal. +* +* @param z1 - first complex number +* @param z2 - second complex number +* @returns boolean indicating if both complex numbers are equal +* +* @example +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* +* var z1 = new Complex64( 5.0, 3.0 ); +* var z2 = new Complex64( 5.0, 3.0 ); +* +* var v = isEqualf( z1, z2 ); +* // returns true +*/ +declare function isEqualf( z1: Complex64, z2: Complex64 ): boolean; + + +// EXPORTS // + +export = isEqualf; diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/docs/types/test.ts b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/docs/types/test.ts new file mode 100644 index 00000000000..3c7c23ba540 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/docs/types/test.ts @@ -0,0 +1,67 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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 Complex64 = require( '@stdlib/complex/float32/ctor' ); +import isEqualf = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + const z1 = new Complex64( 5.0, 3.0 ); + const z2 = new Complex64( 5.0, 3.0 ); + + isEqualf( z1, z2 ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided a first argument that is not a complex number... +{ + const z2 = new Complex64( 5.0, 3.0 ); + + isEqualf( 'abc', z2 ); // $ExpectError + isEqualf( 123, z2 ); // $ExpectError + isEqualf( true, z2 ); // $ExpectError + isEqualf( false, z2 ); // $ExpectError + isEqualf( [], z2 ); // $ExpectError + isEqualf( {}, z2 ); // $ExpectError + isEqualf( ( x: number ): number => x, z2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument that is not a complex number... +{ + const z1 = new Complex64( 5.0, 3.0 ); + + isEqualf( z1, 'abc' ); // $ExpectError + isEqualf( z1, 123 ); // $ExpectError + isEqualf( z1, true ); // $ExpectError + isEqualf( z1, false ); // $ExpectError + isEqualf( z1, [] ); // $ExpectError + isEqualf( z1, {} ); // $ExpectError + isEqualf( z1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const z1 = new Complex64( 5.0, 3.0 ); + const z2 = new Complex64( 5.0, 3.0 ); + + isEqualf(); // $ExpectError + isEqualf( z1 ); // $ExpectError + isEqualf( z1, z2, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/examples/c/Makefile b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/examples/c/Makefile new file mode 100644 index 00000000000..6aed70daf16 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 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/float32/base/assert/is-equal/examples/c/example.c b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/examples/c/example.c new file mode 100644 index 00000000000..df732c4f039 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/examples/c/example.c @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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/float32/base/assert/is_equal.h" +#include "stdlib/complex/float32/ctor.h" +#include +#include + +int main( void ) { + const stdlib_complex64_t z[] = { + stdlib_complex64( 5.0f, 2.0f ), + stdlib_complex64( -2.0f, 1.0f ), + stdlib_complex64( 0.0f, -0.0f ), + stdlib_complex64( 0.0f/0.0f, 0.0f/0.0f ) + }; + + bool v; + int i; + for ( i = 0; i < 4; i++ ) { + v = stdlib_base_complex64_is_equal( z[ i ], z[ i ] ); + printf( "Equal? %s\n", ( v ) ? "True" : "False" ); + } +} diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/examples/index.js b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/examples/index.js new file mode 100644 index 00000000000..9451108ba7b --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/examples/index.js @@ -0,0 +1,37 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 Complex64 = require( '@stdlib/complex/float32/ctor' ); +var isEqualf = require( './../lib' ); + +var z1 = new Complex64( 5.0, 3.0 ); +var z2 = new Complex64( 5.0, 3.0 ); +console.log( isEqualf( z1, z2 ) ); +// => true + +z1 = new Complex64( -5.0, -3.0 ); +z2 = new Complex64( 5.0, 3.0 ); +console.log( isEqualf( z1, z2 ) ); +// => false + +z1 = new Complex64( NaN, 3.0 ); +z2 = new Complex64( NaN, 3.0 ); +console.log( isEqualf( z1, z2 ) ); +// => false diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/include/stdlib/complex/float32/base/assert/is_equal.h b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/include/stdlib/complex/float32/base/assert/is_equal.h new file mode 100644 index 00000000000..b5b0dde12af --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/include/stdlib/complex/float32/base/assert/is_equal.h @@ -0,0 +1,41 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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. +*/ + +#ifndef STDLIB_COMPLEX_FLOAT32_BASE_ASSERT_IS_EQUAL_H +#define STDLIB_COMPLEX_FLOAT32_BASE_ASSERT_IS_EQUAL_H + +#include "stdlib/complex/float32/ctor.h" +#include + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Tests whether two single-precision complex floating-point numbers are equal. +*/ +bool stdlib_base_complex64_is_equal( const stdlib_complex64_t z1, const stdlib_complex64_t z2 ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_COMPLEX_FLOAT32_BASE_ASSERT_IS_EQUAL_H diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/lib/index.js b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/lib/index.js new file mode 100644 index 00000000000..c8820d782b8 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/lib/index.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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'; + +/** +* Test whether two single-precision complex floating-point numbers are equal. +* +* @module @stdlib/complex/float32/base/assert/is-equal +* +* @example +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var isEqualf = require( '@stdlib/complex/float32/base/assert/is-equal' ); +* +* var z1 = new Complex64( 5.0, 3.0 ); +* var z2 = new Complex64( 5.0, 3.0 ); +* +* var v = isEqualf( z1, z2 ); +* // returns true +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/lib/main.js b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/lib/main.js new file mode 100644 index 00000000000..0e9b0c707f4 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/lib/main.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 reimf = require( '@stdlib/complex/reimf' ); + + +// MAIN // + +/** +* Tests whether two single-precision complex floating-point numbers are equal. +* +* @param {Complex64} z1 - first complex number +* @param {Complex64} z2 - second complex number +* @returns {boolean} result +* +* @example +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* +* var z1 = new Complex64( 5.0, 3.0 ); +* var z2 = new Complex64( 5.0, 3.0 ); +* +* var v = isEqualf( z1, z2 ); +* // returns true +*/ +function isEqualf( z1, z2 ) { + var parts1 = reimf( z1 ); + var parts2 = reimf( z2 ); + return ( + parts1[ 0 ] === parts2[ 0 ] && + parts1[ 1 ] === parts2[ 1 ] + ); +} + + +// EXPORTS // + +module.exports = isEqualf; diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/manifest.json b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/manifest.json new file mode 100644 index 00000000000..33e095471eb --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/manifest.json @@ -0,0 +1,59 @@ +{ + "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/complex/float32/ctor", + "@stdlib/complex/reimf" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/complex/float32/ctor", + "@stdlib/complex/reimf" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/package.json b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/package.json new file mode 100644 index 00000000000..f0fce101a99 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/package.json @@ -0,0 +1,71 @@ +{ + "name": "@stdlib/complex/float32/base/assert/is-equal", + "version": "0.0.0", + "description": "Test whether two single-precision complex floating-point numbers are equal.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "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", + "complex", + "cmplx", + "number", + "base", + "assert", + "test", + "validate", + "equality", + "compare", + "comparison", + "equal", + "eq" + ] +} diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/src/main.c b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/src/main.c new file mode 100644 index 00000000000..efa0d10b0d4 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/src/main.c @@ -0,0 +1,48 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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/float32/base/assert/is_equal.h" +#include "stdlib/complex/reimf.h" +#include "stdlib/complex/float32/ctor.h" +#include + +/** +* Tests whether two single-precision complex floating-point numbers are equal. +* +* @param z1 first single-precision complex floating-point number +* @param z2 second single-precision complex floating-point number +* @return boolean indicating if both complex numbers are equal +* +* @example +* #include "stdlib/complex/float32/ctor.h" +* #include +* +* stdlib_complex64_t z1 = stdlib_complex64( 5.0, 2.0 ); +* stdlib_complex64_t z2 = stdlib_complex64( 5.0, 2.0 ); +* +* bool v = stdlib_base_complex64_is_equal( z1, z2 ); +*/ +bool stdlib_base_complex64_is_equal( const stdlib_complex64_t z1, const stdlib_complex64_t z2 ) { + float re1; + float re2; + float im1; + float im2; + stdlib_reimf( z1, &re1, &im1 ); + stdlib_reimf( z2, &re2, &im2 ); + return ( re1 == re2 && im1 == im2 ); +} diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/test/test.js b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/test/test.js new file mode 100644 index 00000000000..e320839539c --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-equal/test/test.js @@ -0,0 +1,134 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var isEqualf = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isEqualf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function tests whether two complex numbers are equal (finite)', function test( t ) { + var z1; + var z2; + + z1 = new Complex64( 5.0, 3.0 ); + t.strictEqual( isEqualf( z1, z1 ), true, 'returns expected value' ); + + z1 = new Complex64( 5.0, 3.0 ); + z2 = new Complex64( 5.0, 3.0 ); + t.strictEqual( isEqualf( z1, z2 ), true, 'returns expected value' ); + + z1 = new Complex64( -5.0, 3.0 ); + z2 = new Complex64( 5.0, 3.0 ); + t.strictEqual( isEqualf( z1, z2 ), false, 'returns expected value' ); + + z1 = new Complex64( 5.0, 3.0 ); + z2 = new Complex64( -5.0, 3.0 ); + t.strictEqual( isEqualf( z1, z2 ), false, 'returns expected value' ); + + z1 = new Complex64( 5.0, -3.0 ); + z2 = new Complex64( 5.0, 3.0 ); + t.strictEqual( isEqualf( z1, z2 ), false, 'returns expected value' ); + + z1 = new Complex64( 5.0, 3.0 ); + z2 = new Complex64( 5.0, -3.0 ); + t.strictEqual( isEqualf( z1, z2 ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether two complex numbers are equal (infinite)', function test( t ) { + var z1; + var z2; + + z1 = new Complex64( PINF, NINF ); + t.strictEqual( isEqualf( z1, z1 ), true, 'returns expected value' ); + + z1 = new Complex64( PINF, NINF ); + z2 = new Complex64( PINF, NINF ); + t.strictEqual( isEqualf( z1, z2 ), true, 'returns expected value' ); + + z1 = new Complex64( NINF, 3.0 ); + z2 = new Complex64( PINF, 3.0 ); + t.strictEqual( isEqualf( z1, z2 ), false, 'returns expected value' ); + + z1 = new Complex64( PINF, 3.0 ); + z2 = new Complex64( NINF, 3.0 ); + t.strictEqual( isEqualf( z1, z2 ), false, 'returns expected value' ); + + z1 = new Complex64( PINF, -3.0 ); + z2 = new Complex64( PINF, 3.0 ); + t.strictEqual( isEqualf( z1, z2 ), false, 'returns expected value' ); + + z1 = new Complex64( PINF, 3.0 ); + z2 = new Complex64( PINF, -3.0 ); + t.strictEqual( isEqualf( z1, z2 ), false, 'returns expected value' ); + + z1 = new Complex64( 5.0, PINF ); + z2 = new Complex64( 5.0, NINF ); + t.strictEqual( isEqualf( z1, z2 ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function tests whether two complex numbers are equal (NaNs)', function test( t ) { + var z1; + var z2; + + z1 = new Complex64( NaN, NaN ); + t.strictEqual( isEqualf( z1, z1 ), false, 'returns expected value' ); + + z1 = new Complex64( NaN, NaN ); + z2 = new Complex64( NaN, NaN ); + t.strictEqual( isEqualf( z1, z2 ), false, 'returns expected value' ); + + z1 = new Complex64( NaN, 3.0 ); + z2 = new Complex64( NaN, 3.0 ); + t.strictEqual( isEqualf( z1, z2 ), false, 'returns expected value' ); + + z1 = new Complex64( 5.0, 3.0 ); + z2 = new Complex64( NaN, 3.0 ); + t.strictEqual( isEqualf( z1, z2 ), false, 'returns expected value' ); + + z1 = new Complex64( NaN, 3.0 ); + z2 = new Complex64( 5.0, 3.0 ); + t.strictEqual( isEqualf( z1, z2 ), false, 'returns expected value' ); + + z1 = new Complex64( 5.0, NaN ); + z2 = new Complex64( 5.0, NaN ); + t.strictEqual( isEqualf( z1, z2 ), false, 'returns expected value' ); + + z1 = new Complex64( 5.0, 3.0 ); + z2 = new Complex64( 5.0, NaN ); + t.strictEqual( isEqualf( z1, z2 ), false, 'returns expected value' ); + + t.end(); +});