From 64f07815729ee016349ebbdaf09bbcce17f09a1e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 16 Jun 2024 04:14:21 +0000 Subject: [PATCH] Auto-generated commit --- CHANGELOG.md | 3 ++ base/ops/cdiv/lib/main.js | 2 +- base/ops/cdiv/src/main.c | 28 ++++++++----- base/ops/cdiv/test/test.js | 52 +++++++++++------------ base/ops/cdiv/test/test.native.js | 68 +++++++++++++++++-------------- 5 files changed, 86 insertions(+), 67 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9823e892a..76e969d77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -560,6 +560,7 @@ This release closes the following issue: ##### Bug Fixes +- [`53cf211`](https://github.com/stdlib-js/stdlib/commit/53cf211f341dc87077710b30ac41a0938e83b773) - use correct assignment and adjust test tolerances - [`cf3f92e`](https://github.com/stdlib-js/stdlib/commit/cf3f92eddd20ec1a4106c8a34f7d7705a9a99dbc) - update include paths @@ -4598,6 +4599,7 @@ A total of 28 people contributed to this release. Thank you to the following con
+- [`53cf211`](https://github.com/stdlib-js/stdlib/commit/53cf211f341dc87077710b30ac41a0938e83b773) - **fix:** use correct assignment and adjust test tolerances _(by Athan Reines)_ - [`11c882d`](https://github.com/stdlib-js/stdlib/commit/11c882dcc261abe6a898a3061b45af7f0d4a41cd) - **chore:** update package meta data [(##2379)](#2379) _(by stdlib-bot, Athan Reines)_ - [`7b85db8`](https://github.com/stdlib-js/stdlib/commit/7b85db803f6a6bce2999bfe8b2513edb08e15a67) - **feat:** add C implementation for `math/base/special/covercos` [(##2377)](#2377) _(by Gunj Joshi)_ - [`e7938d9`](https://github.com/stdlib-js/stdlib/commit/e7938d964046b7a61dbc89d23f39daebf4545a47) - **feat:** add C implementation for `math/base/special/cscd` [(##2378)](#2378) _(by Gunj Joshi)_ @@ -4637,6 +4639,7 @@ A total of 28 people contributed to this release. Thank you to the following con - [`1bc3682`](https://github.com/stdlib-js/stdlib/commit/1bc36829f1d4a1508acd17f0ffcdc31167a30f20) - **feat:** add C implementation for `math/base/special/negafibonacci` _(by Gunj Joshi, Pranav Goswami, Philipp Burckhardt)_ - [`1ba660a`](https://github.com/stdlib-js/stdlib/commit/1ba660abde970312ef52b49b3bf0cf3af4200f3d) - **feat:** add C implementation for `math/base/special/fibonacci-index` _(by Gunj Joshi, Philipp Burckhardt)_ - [`3a3b1e0`](https://github.com/stdlib-js/stdlib/commit/3a3b1e08f73a54c5ee46d73045805aee0bb1196d) - **docs:** update package URLs [(##2269)](#2269) _(by stdlib-bot)_ +- [`44aa02f`](https://github.com/stdlib-js/stdlib/commit/44aa02fd4339364a4717ccfac6fc7c1b1ce616bc) - **refactor:** ensure variables are static _(by Athan Reines)_ - [`8089b88`](https://github.com/stdlib-js/stdlib/commit/8089b886a4d7d89f15abb068b1021d93f9c4f64e) - **docs:** update paths _(by Athan Reines)_ - [`038b199`](https://github.com/stdlib-js/stdlib/commit/038b199c32842c02cf678e3ae8305a17aacda05e) - **docs:** update paths _(by Athan Reines)_ - [`e7ebe20`](https://github.com/stdlib-js/stdlib/commit/e7ebe201dea1be826f89b997538638b07f26a960) - **fix:** update implementation to use correct constants _(by Athan Reines)_ diff --git a/base/ops/cdiv/lib/main.js b/base/ops/cdiv/lib/main.js index b396e8f62..81ba685a8 100644 --- a/base/ops/cdiv/lib/main.js +++ b/base/ops/cdiv/lib/main.js @@ -112,7 +112,7 @@ function cdiv( z1, z2 ) { out = robustInternal( re1, im1, re2, im2 ); } else { out = robustInternal( im1, re1, im2, re2 ); - out[ 1 ] *= -1; + out[ 1 ] *= -1.0; } out[ 0 ] *= s; out[ 1 ] *= s; diff --git a/base/ops/cdiv/src/main.c b/base/ops/cdiv/src/main.c index d007e931a..0a3c316a1 100644 --- a/base/ops/cdiv/src/main.c +++ b/base/ops/cdiv/src/main.c @@ -25,9 +25,9 @@ #include "stdlib/constants/float64/smallest_normal.h" #include -const double LARGE_THRESHOLD = STDLIB_CONSTANT_FLOAT64_MAX * 0.5; -const double SMALL_THRESHOLD = STDLIB_CONSTANT_FLOAT64_SMALLEST_NORMAL * ( 2.0 / STDLIB_CONSTANT_FLOAT64_EPS ); -const double RECIP_EPS_SQR = 2.0 / ( STDLIB_CONSTANT_FLOAT64_EPS * STDLIB_CONSTANT_FLOAT64_EPS ); +static const double LARGE_THRESHOLD = STDLIB_CONSTANT_FLOAT64_MAX * 0.5; +static const double SMALL_THRESHOLD = STDLIB_CONSTANT_FLOAT64_SMALLEST_NORMAL * ( 2.0 / STDLIB_CONSTANT_FLOAT64_EPS ); +static const double RECIP_EPS_SQR = 2.0 / ( STDLIB_CONSTANT_FLOAT64_EPS * STDLIB_CONSTANT_FLOAT64_EPS ); /** * Computes the real part of the quotient. @@ -113,6 +113,8 @@ stdlib_complex128_t stdlib_base_cdiv( const stdlib_complex128_t z1, const stdlib double re2; double im1; double im2; + double t1; + double t2; double ab; double cd; double re; @@ -122,15 +124,19 @@ stdlib_complex128_t stdlib_base_cdiv( const stdlib_complex128_t z1, const stdlib stdlib_reim( z1, &re1, &im1 ); stdlib_reim( z2, &re2, &im2 ); - if ( stdlib_base_abs( re1 ) > stdlib_base_abs( im1 ) ){ - ab = re1; + t1 = stdlib_base_abs( re1 ); + t2 = stdlib_base_abs( im1 ); + if ( t1 > t2 ){ + ab = t1; } else { - ab = im1; + ab = t2; } - if ( stdlib_base_abs( re2 ) > stdlib_base_abs( im2 ) ){ - cd = re2; + t1 = stdlib_base_abs( re2 ); + t2 = stdlib_base_abs( im2 ); + if ( t1 > t2 ){ + cd = t1; } else { - cd = im2; + cd = t2; } s = 1.0; @@ -153,11 +159,13 @@ stdlib_complex128_t stdlib_base_cdiv( const stdlib_complex128_t z1, const stdlib im2 *= RECIP_EPS_SQR; s *= RECIP_EPS_SQR; } + re = 0.0; + im = 0.0; if ( stdlib_base_abs( im2 ) <= stdlib_base_abs( re2 ) ) { robustInternal( re1, im1, re2, im2, &re, &im ); } else { robustInternal( im1, re1, im2, re2, &re, &im ); - im *= -1; + im *= -1.0; } re *= s; im *= s; diff --git a/base/ops/cdiv/test/test.js b/base/ops/cdiv/test/test.js index b7bd232ca..234c49295 100644 --- a/base/ops/cdiv/test/test.js +++ b/base/ops/cdiv/test/test.js @@ -322,14 +322,14 @@ tape( 'the function computes a complex quotient (tested against fixtures)', func } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -366,14 +366,14 @@ tape( 'the function computes a complex quotient (different component scales)', f } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -410,14 +410,14 @@ tape( 'the function computes a complex quotient (different component scales)', f } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -454,14 +454,14 @@ tape( 'the function computes a complex quotient (different imaginary component s } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -498,14 +498,14 @@ tape( 'the function computes a complex quotient (real imaginary component scales } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -542,14 +542,14 @@ tape( 'the function computes a complex quotient (large negative imaginary compon } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -586,14 +586,14 @@ tape( 'the function computes a complex quotient (large negative real components) } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -630,14 +630,14 @@ tape( 'the function computes a complex quotient (large positive imaginary compon } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -674,14 +674,14 @@ tape( 'the function computes a complex quotient (large positive real components) } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -718,14 +718,14 @@ tape( 'the function computes a complex quotient (tiny negative imaginary compone } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -762,14 +762,14 @@ tape( 'the function computes a complex quotient (tiny negative real components)' } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -806,14 +806,14 @@ tape( 'the function computes a complex quotient (tiny positive imaginary compone } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -850,14 +850,14 @@ tape( 'the function computes a complex quotient (tiny positive real components)' } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); diff --git a/base/ops/cdiv/test/test.native.js b/base/ops/cdiv/test/test.native.js index e54b78eda..002e9d432 100644 --- a/base/ops/cdiv/test/test.native.js +++ b/base/ops/cdiv/test/test.native.js @@ -330,15 +330,19 @@ tape( 'the function computes a complex quotient (tested against fixtures)', opts t.strictEqual( real( q ), qre[ i ], 'returns expected real component' ); } else { delta = abs( real( q ) - qre[ i ] ); - tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + tol = 2.0 * EPS * abs( qre[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+real(q)+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); - tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + tol = 2.0 * EPS * abs( qim[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+imag(q)+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -375,14 +379,14 @@ tape( 'the function computes a complex quotient (different component scales)', o } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+real(q)+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+imag(q)+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -419,14 +423,14 @@ tape( 'the function computes a complex quotient (different component scales)', o } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+real(q)+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+imag(q)+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -463,14 +467,14 @@ tape( 'the function computes a complex quotient (different imaginary component s } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+real(q)+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+imag(q)+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -507,14 +511,14 @@ tape( 'the function computes a complex quotient (real imaginary component scales } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+real(q)+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+imag(q)+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -551,14 +555,14 @@ tape( 'the function computes a complex quotient (large negative imaginary compon } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+real(q)+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+imag(q)+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -595,14 +599,14 @@ tape( 'the function computes a complex quotient (large negative real components) } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+real(q)+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+imag(q)+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -639,14 +643,14 @@ tape( 'the function computes a complex quotient (large positive imaginary compon } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+real(q)+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+imag(q)+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -682,15 +686,19 @@ tape( 'the function computes a complex quotient (large positive real components) t.strictEqual( real( q ), qre[ i ], 'returns expected real component' ); } else { delta = abs( real( q ) - qre[ i ] ); - tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + tol = 2.0 * EPS * abs( qre[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+real(q)+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); - tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + tol = 2.0 * EPS * abs( qim[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+imag(q)+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -727,14 +735,14 @@ tape( 'the function computes a complex quotient (tiny negative imaginary compone } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+real(q)+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+imag(q)+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -771,14 +779,14 @@ tape( 'the function computes a complex quotient (tiny negative real components)' } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+real(q)+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+imag(q)+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -815,14 +823,14 @@ tape( 'the function computes a complex quotient (tiny positive imaginary compone } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+real(q)+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+imag(q)+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end(); @@ -859,14 +867,14 @@ tape( 'the function computes a complex quotient (tiny positive real components)' } else { delta = abs( real( q ) - qre[ i ] ); tol = EPS * abs( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. real: '+q[0]+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. real: '+real(q)+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } if ( imag( q ) === qim[ i ] ) { t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' ); } else { delta = abs( imag( q ) - qim[ i ] ); tol = EPS * abs( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+'+ '+im1[i]+'i. y: '+re2[i]+'+ '+im2[i]+'i. imag: '+q[1]+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); + t.ok( delta <= tol, 'within tolerance. x: '+re1[i]+' + '+im1[i]+'i. y: '+re2[i]+' + '+im2[i]+'i. imag: '+imag(q)+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); } } t.end();