Skip to content

Commit bf55c95

Browse files
committed
Auto-generated commit
1 parent 35433d7 commit bf55c95

6 files changed

Lines changed: 41 additions & 44 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-09-02)
7+
## Unreleased (2025-09-03)
88

99
<section class="features">
1010

@@ -158,6 +158,7 @@
158158

159159
### Bug Fixes
160160

161+
- [`5a7e089`](https://github.com/stdlib-js/stdlib/commit/5a7e089cae843c60489c0b222f41fc29f405c36d) - use correct `f32` emulation
161162
- [`25ed2e6`](https://github.com/stdlib-js/stdlib/commit/25ed2e674ecd5d5c29aebde65b7f57d3bcabdda2) - use single-precision float literal in comparison for `math/base/special/fast/absf`
162163
- [`0e4ba2c`](https://github.com/stdlib-js/stdlib/commit/0e4ba2ca838ee0cbb11d1511280549e47442b735) - remove unneeded #include
163164
- [`4d6978d`](https://github.com/stdlib-js/stdlib/commit/4d6978d4d38a3b44266a22199a81e8eb848741fb) - correct argument order for iid_d in `math/base/napi/ternary` NAPI function
@@ -632,6 +633,9 @@ A total of 62 issues were closed in this release:
632633

633634
<details>
634635

636+
- [`fe96d97`](https://github.com/stdlib-js/stdlib/commit/fe96d973306fc6d28936c6150c160fb5d1f590c7) - **test:** use `ulpdiff` for floating-point comparisons _(by Karan Anand)_
637+
- [`3ab83ba`](https://github.com/stdlib-js/stdlib/commit/3ab83ba5fd5e559b7304fc560872c8936b9cff60) - **test:** update fixtures to use `Float32` inputs _(by Karan Anand)_
638+
- [`5a7e089`](https://github.com/stdlib-js/stdlib/commit/5a7e089cae843c60489c0b222f41fc29f405c36d) - **fix:** use correct `f32` emulation _(by Karan Anand)_
635639
- [`ec60fa2`](https://github.com/stdlib-js/stdlib/commit/ec60fa2056184a44d871da8228647cbed60274ab) - **docs:** fix `hypotf` description across package _(by Philipp Burckhardt)_
636640
- [`c8b2a70`](https://github.com/stdlib-js/stdlib/commit/c8b2a7011179f4326a31fc018ab9fcd35b9144e2) - **feat:** add `math/base/special/fast/hypotf` [(#7998)](https://github.com/stdlib-js/stdlib/pull/7998) _(by Nakul Krishnakumar)_
637641
- [`b5a845c`](https://github.com/stdlib-js/stdlib/commit/b5a845c7043bb3818348283b9bfd2a5440a39845) - **docs:** update related packages sections [(#8001)](https://github.com/stdlib-js/stdlib/pull/8001) _(by stdlib-bot)_

base/special/fast/hypotf/lib/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// MODULES //
2222

2323
var sqrtf = require( './../../../../../base/special/sqrtf' );
24+
var f32 = require( '@stdlib/number/float64/base/to-float32' );
2425

2526

2627
// MAIN //
@@ -37,7 +38,9 @@ var sqrtf = require( './../../../../../base/special/sqrtf' );
3738
* // returns 13.0
3839
*/
3940
function hypotf( x, y ) {
40-
return sqrtf( ( x * x ) + ( y * y ) );
41+
x = f32( x );
42+
y = f32( y );
43+
return sqrtf( f32( f32( x * x ) + f32( y * y ) ) );
4144
}
4245

4346

base/special/fast/hypotf/test/fixtures/julia/data.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

base/special/fast/hypotf/test/fixtures/julia/runner.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ julia> gen( x, y, \"data.json\" );
3838
```
3939
"""
4040
function gen( x, y, name )
41-
h = hypot.( x, y );
41+
h = hypot.( convert( Array{Float32}, x ), convert( Array{Float32}, y ) );
4242

4343
# Store data to be written to file as a collection:
4444
data = Dict([

base/special/fast/hypotf/test/test.js

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24+
var f32 = require( '@stdlib/number/float64/base/to-float32' );
25+
var ulpdiff = require( '@stdlib/number/float32/base/ulp-difference' );
2426
var PINF = require( '@stdlib/constants/float32/pinf' );
25-
var EPS = require( '@stdlib/constants/float32/eps' );
26-
var absf = require( './../../../../../base/special/absf' );
2727
var hypotf = require( './../lib' );
2828

2929

@@ -42,8 +42,6 @@ tape( 'main export is a function', function test( t ) {
4242

4343
tape( 'the function computes the hypotenuse', function test( t ) {
4444
var expected;
45-
var delta;
46-
var tol;
4745
var h;
4846
var x;
4947
var y;
@@ -54,41 +52,38 @@ tape( 'the function computes the hypotenuse', function test( t ) {
5452
expected = data.expected;
5553

5654
for ( i = 0; i < x.length; i++ ) {
55+
x[ i ] = f32( x[ i ] );
56+
y[ i ] = f32( y[ i ] );
57+
expected[ i ] = f32( expected[ i ] );
5758
h = hypotf( x[ i ], y[ i ] );
58-
if ( h === expected[ i ] ) {
59-
t.ok( true, 'x: '+x[ i ]+'. y: '+y[ i ]+'. h: '+h+'. Expected: '+expected[ i ]+'.' );
60-
} else {
61-
delta = absf( h - expected[ i ] );
62-
tol = 1.4 * EPS * absf( expected[ i ] );
63-
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y[ i ]+'. h: '+h+'. Expected: '+expected[ i ]+'. Delta: '+delta+'. Tol: '+tol+'.' );
64-
}
59+
t.strictEqual( ulpdiff( h, expected[ i ] ) <= 1, true, 'returns expected value' );
6560
}
6661
t.end();
6762
});
6863

6964
tape( 'the function computes the hypotenuse (canonical inputs)', function test( t ) {
7065
var h;
7166

72-
h = hypotf( 3.0, 4.0 );
73-
t.strictEqual( h, 5.0, 'returns expected value' );
67+
h = hypotf( f32( 3.0 ), f32( 4.0 ) );
68+
t.strictEqual( h, f32( 5.0 ), 'returns expected value' );
7469

75-
h = hypotf( 6.0, 8.0 );
76-
t.strictEqual( h, 10.0, 'returns expected value' );
70+
h = hypotf( f32( 6.0 ), f32( 8.0 ) );
71+
t.strictEqual( h, f32( 10.0 ), 'returns expected value' );
7772

78-
h = hypotf( 5.0, 12.0 );
79-
t.strictEqual( h, 13.0, 'returns expected value' );
73+
h = hypotf( f32( 5.0 ), f32( 12.0 ) );
74+
t.strictEqual( h, f32( 13.0 ), 'returns expected value' );
8075

8176
t.end();
8277
});
8378

8479
tape( 'the function can overflow', function test( t ) {
85-
var h = hypotf( 1.0e38, 1.0e38 );
80+
var h = hypotf( f32( 1.0e38 ), f32( 1.0e38 ) );
8681
t.strictEqual( h, PINF, 'returns expected value' );
8782
t.end();
8883
});
8984

9085
tape( 'the function can underflow', function test( t ) {
91-
var h = hypotf( 1.0e-45, 1.0e-45 );
92-
t.strictEqual( h, 0.0, 'returns expected value' );
86+
var h = hypotf( f32( 1.0e-45 ), f32( 1.0e-45 ) );
87+
t.strictEqual( h, f32( 0.0 ), 'returns expected value' );
9388
t.end();
9489
});

base/special/fast/hypotf/test/test.native.js

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var tape = require( 'tape' );
25+
var f32 = require( '@stdlib/number/float64/base/to-float32' );
26+
var ulpdiff = require( '@stdlib/number/float32/base/ulp-difference' );
2527
var PINF = require( '@stdlib/constants/float32/pinf' );
26-
var EPS = require( '@stdlib/constants/float32/eps' );
2728
var tryRequire = require( '@stdlib/utils/try-require' );
28-
var absf = require( './../../../../../base/special/absf' );
2929

3030

3131
// VARIABLES //
@@ -51,8 +51,6 @@ tape( 'main export is a function', opts, function test( t ) {
5151

5252
tape( 'the function computes the hypotenuse', opts, function test( t ) {
5353
var expected;
54-
var delta;
55-
var tol;
5654
var h;
5755
var x;
5856
var y;
@@ -63,41 +61,38 @@ tape( 'the function computes the hypotenuse', opts, function test( t ) {
6361
expected = data.expected;
6462

6563
for ( i = 0; i < x.length; i++ ) {
64+
x[ i ] = f32( x[ i ] );
65+
y[ i ] = f32( y[ i ] );
66+
expected[ i ] = f32( expected[ i ] );
6667
h = hypotf( x[ i ], y[ i ] );
67-
if ( h === expected[ i ] ) {
68-
t.ok( true, 'x: '+x[ i ]+'. y: '+y[ i ]+'. h: '+h+'. Expected: '+expected[ i ]+'.' );
69-
} else {
70-
delta = absf( h - expected[ i ] );
71-
tol = 1.4 * EPS * absf( expected[ i ] );
72-
t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y[ i ]+'. h: '+h+'. Expected: '+expected[ i ]+'. Delta: '+delta+'. Tol: '+tol+'.' );
73-
}
68+
t.strictEqual( ulpdiff( h, expected[ i ] ) <= 1, true, 'returns expected value' );
7469
}
7570
t.end();
7671
});
7772

7873
tape( 'the function computes the hypotenuse (canonical inputs)', opts, function test( t ) {
7974
var h;
8075

81-
h = hypotf( 3.0, 4.0 );
82-
t.strictEqual( h, 5.0, 'returns expected value' );
76+
h = hypotf( f32( 3.0 ), f32( 4.0 ) );
77+
t.strictEqual( h, f32( 5.0 ), 'returns expected value' );
8378

84-
h = hypotf( 6.0, 8.0 );
85-
t.strictEqual( h, 10.0, 'returns expected value' );
79+
h = hypotf( f32( 6.0 ), f32( 8.0 ) );
80+
t.strictEqual( h, f32( 10.0 ), 'returns expected value' );
8681

87-
h = hypotf( 5.0, 12.0 );
88-
t.strictEqual( h, 13.0, 'returns expected value' );
82+
h = hypotf( f32( 5.0 ), f32( 12.0 ) );
83+
t.strictEqual( h, f32( 13.0 ), 'returns expected value' );
8984

9085
t.end();
9186
});
9287

9388
tape( 'the function can overflow', opts, function test( t ) {
94-
var h = hypotf( 1.0e38, 1.0e38 );
89+
var h = hypotf( f32( 1.0e38 ), f32( 1.0e38 ) );
9590
t.strictEqual( h, PINF, 'returns expected value' );
9691
t.end();
9792
});
9893

9994
tape( 'the function can underflow', opts, function test( t ) {
100-
var h = hypotf( 1.0e-45, 1.0e-45 );
101-
t.strictEqual( h, 0.0, 'returns expected value' );
95+
var h = hypotf( f32( 1.0e-45 ), f32( 1.0e-45 ) );
96+
t.strictEqual( h, f32( 0.0 ), 'returns expected value' );
10297
t.end();
10398
});

0 commit comments

Comments
 (0)