diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/README.md b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/README.md new file mode 100644 index 000000000000..5d3dc85c40f4 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/README.md @@ -0,0 +1,158 @@ + + +# isAlmostEqualf + +> Test whether two single-precision complex floating-point numbers are approximately equal within a specified number of ULPs (units in the last place). + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var isAlmostEqualf = require( '@stdlib/complex/float32/base/assert/is-almost-equal' ); +``` + +#### isAlmostEqualf( z1, z2, maxULP ) + +Tests whether two single-precision complex floating-point numbers are approximately equal within a specified number of ULPs (units in the last place). + +```javascript +var EPS = require( '@stdlib/constants/float32/eps' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); + +var z1 = new Complex64( 1.0, 3.0 ); +var z2 = new Complex64( 1.0+EPS, 3.0 ); + +var out = isAlmostEqualf( z1, z2, 0 ); +// returns false + +out = isAlmostEqualf( z1, z2, 1 ); +// returns true +``` + +The function returns `false` if either input value has a `NaN` real or imaginary component. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); + +var z1 = new Complex64( NaN, 3.0 ); +var z2 = new Complex64( 1.0, 3.0 ); + +var out = isAlmostEqualf( z1, z2, 1 ); +// returns false + +out = isAlmostEqualf( z2, z1, 1 ); +// returns false + +z1 = new Complex64( NaN, NaN ); +z2 = new Complex64( NaN, NaN ); + +out = isAlmostEqualf( z1, z2, 1 ); +// returns false +``` + +The function does not distinguish between `-0` and `+0`, treating them as equal. + +```javascript +var Complex64 = require( '@stdlib/complex/float32/ctor' ); + +var z1 = new Complex64( 0.0, 0.0 ); +var z2 = new Complex64( -0.0, -0.0 ); + +var out = isAlmostEqualf( z1, z2, 0 ); +// returns true +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var EPS = require( '@stdlib/constants/float32/eps' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var isAlmostEqualf = require( '@stdlib/complex/float32/base/assert/is-almost-equal' ); + +var z1 = new Complex64( 1.0, 3.0+EPS ); +var z2 = new Complex64( 1.0+EPS, 3.0 ); +console.log( isAlmostEqualf( z1, z2, 1 ) ); +// => true + +z1 = new Complex64( 1.0, 3.0+EPS ); +z2 = new Complex64( 1.0+EPS+EPS, 3.0 ); +console.log( isAlmostEqualf( z1, z2, 1 ) ); +// => false + +z1 = new Complex64( 0.0, 0.0 ); +z2 = new Complex64( -0.0, 0.0 ); +console.log( isAlmostEqualf( z1, z2, 0 ) ); +// => true + +z1 = new Complex64( NaN, 0.0 ); +z2 = new Complex64( 1.0, 0.0 ); +console.log( isAlmostEqualf( z1, z2, 1 ) ); +// => false +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/benchmark/benchmark.js b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/benchmark/benchmark.js new file mode 100644 index 000000000000..e39b97d685ab --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/benchmark/benchmark.js @@ -0,0 +1,63 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var 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 isAlmostEqualf = 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 = isAlmostEqualf( z1[ i%z1.length ], z2[ i%z2.length ], 1 ); + 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-almost-equal/docs/repl.txt b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/docs/repl.txt new file mode 100644 index 000000000000..96d628f0dfb1 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/docs/repl.txt @@ -0,0 +1,45 @@ + +{{alias}}( z1, z2, maxULP ) + Tests whether two single-precision complex floating-point numbers are + approximately equal within a specified number of ULPs (units in the last + place). + + The function returns `false` if either input value has a `NaN` real or + imaginary component. + + The function does not distinguish between `-0` and `+0`, treating them as + equal. + + Parameters + ---------- + z1: Complex64 + First complex number. + + z2: Complex64 + Second complex number. + + maxULP: number + Maximum allowed ULP difference. + + Returns + ------- + out: boolean + Boolean indicating whether two single-precision complex floating-point + numbers are approximately equal within a specified number of ULPs. + + Examples + -------- + > var re1 = 1.0; + > var im1 = 3.0; + > var re2 = 1.0 + {{alias:@stdlib/constants/float32/eps}}; + > var im2 = 3.0; + > var z1 = new {{alias:@stdlib/complex/float32/ctor}}( re1, im1 ); + > var z2 = new {{alias:@stdlib/complex/float32/ctor}}( re2, im2 ); + > var v = {{alias}}( z1, z2, 0 ) + false + > v = {{alias}}( z1, z2, 1 ) + true + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/docs/types/index.d.ts b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/docs/types/index.d.ts new file mode 100644 index 000000000000..ba3350fb424f --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/docs/types/index.d.ts @@ -0,0 +1,54 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +import Complex64 = require( '@stdlib/complex/float32/ctor' ); + +/** +* Tests whether two single-precision complex floating-point numbers are approximately equal within a specified number of ULPs (units in the last place). +* +* ## Notes +* +* - The function returns `false` if either input value has a `NaN` real or imaginary component. +* - The function does not distinguish between `-0` and `+0`, treating them as equal. +* +* @param z1 - first complex number +* @param z2 - second complex number +* @param maxULP - maximum allowed ULP difference +* @returns boolean indicating whether two single-precision complex floating-point numbers are approximately equal within a specified number of ULPs +* +* @example +* var EPS = require( '@stdlib/constants/float32/eps' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* +* var z1 = new Complex64( 1.0, 3.0 ); +* var z2 = new Complex64( 1.0+EPS, 3.0 ); +* +* var bool = isAlmostEqualf( z1, z2, 0 ); +* // returns false +* +* bool = isAlmostEqualf( z1, z2, 1 ); +* // returns true +*/ +declare function isAlmostEqualf( z1: Complex64, z2: Complex64, maxULP: number ): boolean; + + +// EXPORTS // + +export = isAlmostEqualf; diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/docs/types/test.ts b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/docs/types/test.ts new file mode 100644 index 000000000000..2aaf1c802396 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/docs/types/test.ts @@ -0,0 +1,68 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import Complex64 = require( '@stdlib/complex/float32/ctor' ); +import isAlmostEqualf = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + const z1 = new Complex64( 5.0, 3.0 ); + const z2 = new Complex64( 5.0, 3.0 ); + + isAlmostEqualf( z1, z2, 1 ); // $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 ); + + isAlmostEqualf( 'abc', z2, 1 ); // $ExpectError + isAlmostEqualf( 123, z2, 1 ); // $ExpectError + isAlmostEqualf( true, z2, 1 ); // $ExpectError + isAlmostEqualf( false, z2, 1 ); // $ExpectError + isAlmostEqualf( [], z2, 1 ); // $ExpectError + isAlmostEqualf( {}, z2, 1 ); // $ExpectError + isAlmostEqualf( ( x: number ): number => x, z2, 1 ); // $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 ); + + isAlmostEqualf( z1, 'abc', 1 ); // $ExpectError + isAlmostEqualf( z1, 123, 1 ); // $ExpectError + isAlmostEqualf( z1, true, 1 ); // $ExpectError + isAlmostEqualf( z1, false, 1 ); // $ExpectError + isAlmostEqualf( z1, [], 1 ); // $ExpectError + isAlmostEqualf( z1, {}, 1 ); // $ExpectError + isAlmostEqualf( z1, ( x: number ): number => x, 1 ); // $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 ); + + isAlmostEqualf(); // $ExpectError + isAlmostEqualf( z1 ); // $ExpectError + isAlmostEqualf( z1, z2 ); // $ExpectError + isAlmostEqualf( z1, z2, 1, 1 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/examples/index.js b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/examples/index.js new file mode 100644 index 000000000000..0533acf087d5 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/examples/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var EPS = require( '@stdlib/constants/float32/eps' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var isAlmostEqualf = require( './../lib' ); + +var z1 = new Complex64( 1.0, 3.0+EPS ); +var z2 = new Complex64( 1.0+EPS, 3.0 ); +console.log( isAlmostEqualf( z1, z2, 1 ) ); +// => true + +z1 = new Complex64( 1.0, 3.0+EPS ); +z2 = new Complex64( 1.0+EPS+EPS, 3.0 ); +console.log( isAlmostEqualf( z1, z2, 1 ) ); +// => false + +z1 = new Complex64( 0.0, 0.0 ); +z2 = new Complex64( -0.0, 0.0 ); +console.log( isAlmostEqualf( z1, z2, 0 ) ); +// => true + +z1 = new Complex64( NaN, 0.0 ); +z2 = new Complex64( 1.0, 0.0 ); +console.log( isAlmostEqualf( z1, z2, 1 ) ); +// => false diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/lib/index.js b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/lib/index.js new file mode 100644 index 000000000000..9d2010758e71 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/lib/index.js @@ -0,0 +1,48 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Test whether two single-precision complex floating-point numbers are approximately equal within a specified number of ULPs (units in the last place). +* +* @module @stdlib/complex/float32/base/assert/is-almost-equal +* +* @example +* var EPS = require( '@stdlib/constants/float32/eps' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* var isAlmostEqualf = require( '@stdlib/complex/float32/base/assert/is-almost-equal' ); +* +* var z1 = new Complex64( 1.0, 3.0 ); +* var z2 = new Complex64( 1.0+EPS, 3.0 ); +* +* var bool = isAlmostEqualf( z1, z2, 0 ); +* // returns false +* +* bool = isAlmostEqualf( z1, z2, 1 ); +* // returns true +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/lib/main.js b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/lib/main.js new file mode 100644 index 000000000000..13695a41008d --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/lib/main.js @@ -0,0 +1,67 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isAlmostEqualF32 = require( '@stdlib/number/float32/base/assert/is-almost-equal' ); +var reimf = require( '@stdlib/complex/float32/reim' ); + + +// MAIN // + +/** +* Tests whether two single-precision complex floating-point numbers are approximately equal within a specified number of ULPs (units in the last place). +* +* ## Notes +* +* - The function returns `false` if either input value has a `NaN` real or imaginary component. +* - The function does not distinguish between `-0` and `+0`, treating them as equal. +* +* @param {Complex64} z1 - first complex number +* @param {Complex64} z2 - second complex number +* @param {number} maxULP - maximum allowed ULP difference +* @returns {boolean} boolean indicating whether two single-precision complex floating-point numbers are approximately equal within a specified number of ULPs +* +* @example +* var EPS = require( '@stdlib/constants/float32/eps' ); +* var Complex64 = require( '@stdlib/complex/float32/ctor' ); +* +* var z1 = new Complex64( 1.0, 3.0 ); +* var z2 = new Complex64( 1.0+EPS, 3.0 ); +* +* var bool = isAlmostEqualf( z1, z2, 0 ); +* // returns false +* +* bool = isAlmostEqualf( z1, z2, 1 ); +* // returns true +*/ +function isAlmostEqualf( z1, z2, maxULP ) { + var parts1 = reimf( z1 ); + var parts2 = reimf( z2 ); + return ( + isAlmostEqualF32( parts1[ 0 ], parts2[ 0 ], maxULP ) && + isAlmostEqualF32( parts1[ 1 ], parts2[ 1 ], maxULP ) + ); +} + + +// EXPORTS // + +module.exports = isAlmostEqualf; diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/package.json b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/package.json new file mode 100644 index 000000000000..be9eb7aa94d7 --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/package.json @@ -0,0 +1,73 @@ +{ + "name": "@stdlib/complex/float32/base/assert/is-almost-equal", + "version": "0.0.0", + "description": "Test whether two single-precision complex floating-point numbers are approximately equal within a specified number of ULPs (units in the last place).", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "complex", + "cmplx", + "number", + "base", + "assert", + "test", + "validate", + "equality", + "compare", + "comparison", + "equal", + "eq", + "same", + "issame", + "isequal", + "isalmostequal" + ] +} diff --git a/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/test/test.js b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/test/test.js new file mode 100644 index 000000000000..9213752c6e9e --- /dev/null +++ b/lib/node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/test/test.js @@ -0,0 +1,125 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Complex64 = require( '@stdlib/complex/float32/ctor' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var isAlmostEqualf = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isAlmostEqualf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `false` if provided `NaN` as either real or imaginary component', function test( t ) { + var z1; + var z2; + + z1 = new Complex64( NaN, 3.14 ); + z2 = new Complex64( 5.0, 3.14 ); + t.strictEqual( isAlmostEqualf( z1, z2, 1 ), false, 'returns expected value' ); + t.strictEqual( isAlmostEqualf( z2, z1, 1 ), false, 'returns expected value' ); + + z2 = new Complex64( 5.0, NaN ); + t.strictEqual( isAlmostEqualf( z1, z2, 1 ), false, 'returns expected value' ); + t.strictEqual( isAlmostEqualf( z2, z1, 1 ), false, 'returns expected value' ); + + z1 = new Complex64( NaN, NaN ); + z2 = new Complex64( NaN, NaN ); + t.strictEqual( isAlmostEqualf( z1, z2, 1 ), false, 'returns expected value' ); + t.strictEqual( isAlmostEqualf( z2, z1, 1 ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `true` if provided two complex single-precision floating-point numbers which are the same value irrespective of the specified number of ULPs', function test( t ) { + var z1; + var z2; + + z1 = new Complex64( 5.0, 3.0 ); + t.strictEqual( isAlmostEqualf( z1, z1, 0 ), true, 'returns expected value' ); + + z1 = new Complex64( 5.0, 3.0 ); + z2 = new Complex64( 5.0, 3.0 ); + t.strictEqual( isAlmostEqualf( z1, z2, 1 ), true, 'returns expected value' ); + + z1 = new Complex64( -5.0, -3.0 ); + z2 = new Complex64( -5.0, -3.0 ); + t.strictEqual( isAlmostEqualf( z1, z2, 0 ), true, 'returns expected value' ); + + z1 = new Complex64( 0.0, 0.0 ); + z2 = new Complex64( 0.0, 0.0 ); + t.strictEqual( isAlmostEqualf( z1, z2, 0 ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `true` if provided two complex single-precision floating-point numbers which are approximately equal within a specified number of ULPs', function test( t ) { + var z1; + var z2; + + z1 = new Complex64( 1.0, 3.0 ); + z2 = new Complex64( 1.0+EPS, 3.0 ); + t.strictEqual( isAlmostEqualf( z1, z2, 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqualf( z2, z1, 1 ), true, 'returns expected value' ); + + z2 = new Complex64( 1.0+EPS+EPS, 3.0 ); + t.strictEqual( isAlmostEqualf( z1, z2, 2 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqualf( z2, z1, 2 ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `false` if provided two complex single-precision floating-point numbers which are not approximately equal within a specified number of ULPs', function test( t ) { + var z1; + var z2; + + z1 = new Complex64( 1.0, 3.0 ); + z2 = new Complex64( 1.0+EPS, 3.0 ); + t.strictEqual( isAlmostEqualf( z1, z2, 0 ), false, 'returns expected value' ); + t.strictEqual( isAlmostEqualf( z2, z1, 0 ), false, 'returns expected value' ); + + z2 = new Complex64( 1.0+EPS+EPS, 3.0 ); + t.strictEqual( isAlmostEqualf( z1, z2, 1 ), false, 'returns expected value' ); + t.strictEqual( isAlmostEqualf( z2, z1, 1 ), false, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `true` if signed zeros are provided as real or imaginary components irrespective of the specified number of ULPs', function test( t ) { + var z1; + var z2; + + z1 = new Complex64( 0.0, 0.0 ); + z2 = new Complex64( -0.0, -0.0 ); + t.strictEqual( isAlmostEqualf( z1, z2, 0 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqualf( z2, z1, 0 ), true, 'returns expected value' ); + + t.strictEqual( isAlmostEqualf( z1, z2, 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostEqualf( z2, z1, 1 ), true, 'returns expected value' ); + + t.end(); +});