Skip to content

Commit 1c8af8c

Browse files
refactor: replace fmax with stdlib_base_max
PR-URL: #6367 Reviewed-by: Philipp Burckhardt <[email protected]> Reviewed-by: Gunj Joshi <[email protected]>
1 parent 7f74294 commit 1c8af8c

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

lib/node_modules/@stdlib/math/base/special/cinv/manifest.json

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"@stdlib/complex/float64/ctor",
4141
"@stdlib/complex/float64/reim",
4242
"@stdlib/math/base/special/abs",
43+
"@stdlib/math/base/special/max",
4344
"@stdlib/constants/float64/max",
4445
"@stdlib/constants/float64/eps",
4546
"@stdlib/constants/float64/smallest-normal"
@@ -59,6 +60,7 @@
5960
"@stdlib/complex/float64/ctor",
6061
"@stdlib/complex/float64/reim",
6162
"@stdlib/math/base/special/abs",
63+
"@stdlib/math/base/special/max",
6264
"@stdlib/constants/float64/max",
6365
"@stdlib/constants/float64/eps",
6466
"@stdlib/constants/float64/smallest-normal"
@@ -78,6 +80,7 @@
7880
"@stdlib/complex/float64/ctor",
7981
"@stdlib/complex/float64/reim",
8082
"@stdlib/math/base/special/abs",
83+
"@stdlib/math/base/special/max",
8184
"@stdlib/constants/float64/max",
8285
"@stdlib/constants/float64/eps",
8386
"@stdlib/constants/float64/smallest-normal"

lib/node_modules/@stdlib/math/base/special/cinv/src/main.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
#include "stdlib/math/base/special/cinv.h"
2020
#include "stdlib/math/base/special/abs.h"
21+
#include "stdlib/math/base/special/max.h"
2122
#include "stdlib/constants/float64/max.h"
2223
#include "stdlib/constants/float64/eps.h"
2324
#include "stdlib/constants/float64/smallest_normal.h"
2425
#include "stdlib/complex/float64/ctor.h"
2526
#include "stdlib/complex/float64/reim.h"
26-
#include <math.h>
2727

2828

2929
// VARIABLES //
@@ -70,8 +70,7 @@ stdlib_complex128_t stdlib_base_cinv( const stdlib_complex128_t z ) {
7070

7171
stdlib_complex128_reim( z, &re, &im );
7272

73-
// TODO: replace `fmax` with stdlib max implementation once available
74-
ab = fmax( stdlib_base_abs( re ), stdlib_base_abs( im ) );
73+
ab = stdlib_base_max( stdlib_base_abs( re ), stdlib_base_abs( im ) );
7574
s = 1.0;
7675
if ( ab >= LARGE_THRESHOLD ) {
7776
re *= 0.5;

lib/node_modules/@stdlib/math/base/special/cinv/test/test.native.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,18 @@ tape( 'the function computes a complex inverse', opts, function test( t ) {
9595
t.strictEqual( real( q ), qre[ i ], 'returns expected real component' );
9696
} else {
9797
delta = abs( real( q ) - qre[ i ] );
98-
tol = EPS * abs( qre[ i ] );
98+
99+
// 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
100+
tol = 1.8 * EPS * abs( qre[ i ] );
99101
t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+real( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' );
100102
}
101103
if ( imag( q ) === qim[ i ] ) {
102104
t.strictEqual( imag( q ), qim[ i ], 'returns expected imaginary component' );
103105
} else {
104106
delta = abs( imag( q ) - qim[ i ] );
105-
tol = EPS * abs( qim[ i ] );
107+
108+
// 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
109+
tol = 1.7 * EPS * abs( qim[ i ] );
106110
t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imag( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' );
107111
}
108112
}

0 commit comments

Comments
 (0)