Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/cinv/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@stdlib/complex/float64/ctor",
"@stdlib/complex/float64/reim",
"@stdlib/math/base/special/abs",
"@stdlib/math/base/special/max",
"@stdlib/constants/float64/max",
"@stdlib/constants/float64/eps",
"@stdlib/constants/float64/smallest-normal"
Expand All @@ -59,6 +60,7 @@
"@stdlib/complex/float64/ctor",
"@stdlib/complex/float64/reim",
"@stdlib/math/base/special/abs",
"@stdlib/math/base/special/max",
"@stdlib/constants/float64/max",
"@stdlib/constants/float64/eps",
"@stdlib/constants/float64/smallest-normal"
Expand All @@ -78,6 +80,7 @@
"@stdlib/complex/float64/ctor",
"@stdlib/complex/float64/reim",
"@stdlib/math/base/special/abs",
"@stdlib/math/base/special/max",
"@stdlib/constants/float64/max",
"@stdlib/constants/float64/eps",
"@stdlib/constants/float64/smallest-normal"
Expand Down
5 changes: 2 additions & 3 deletions lib/node_modules/@stdlib/math/base/special/cinv/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

#include "stdlib/math/base/special/cinv.h"
#include "stdlib/math/base/special/abs.h"
#include "stdlib/math/base/special/max.h"
#include "stdlib/constants/float64/max.h"
#include "stdlib/constants/float64/eps.h"
#include "stdlib/constants/float64/smallest_normal.h"
#include "stdlib/complex/float64/ctor.h"
#include "stdlib/complex/float64/reim.h"
#include <math.h>


// VARIABLES //
Expand Down Expand Up @@ -70,8 +70,7 @@ stdlib_complex128_t stdlib_base_cinv( const stdlib_complex128_t z ) {

stdlib_complex128_reim( z, &re, &im );

// TODO: replace `fmax` with stdlib max implementation once available
ab = fmax( stdlib_base_abs( re ), stdlib_base_abs( im ) );
ab = stdlib_base_max( stdlib_base_abs( re ), stdlib_base_abs( im ) );
s = 1.0;
if ( ab >= LARGE_THRESHOLD ) {
re *= 0.5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,18 @@ tape( 'the function computes a complex inverse', opts, function test( t ) {
t.strictEqual( real( q ), qre[ i ], 'returns expected real component' );
} else {
delta = abs( real( q ) - qre[ i ] );
tol = EPS * abs( qre[ i ] );

// 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 = 1.8 * EPS * abs( qre[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[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 ] );

// 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 = 1.7 * EPS * abs( qim[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imag( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' );
}
}
Expand Down