Skip to content

Commit f6611fd

Browse files
chore: update benchmark
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: ---
1 parent eaaad1e commit f6611fd

File tree

9 files changed

+74
-67
lines changed

9 files changed

+74
-67
lines changed

lib/node_modules/@stdlib/math/base/special/atan2f/benchmark/benchmark.js

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

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2626
var atan2f = require( '@stdlib/math/base/special/atan2f' );
2727
var pkg = require( './../package.json' ).name;
@@ -35,11 +35,12 @@ bench( pkg, function benchmark( b ) {
3535
var z;
3636
var i;
3737

38+
x = uniform( 100, 0.0, 100 );
39+
y = uniform( 100, 0.0, 100 );
40+
3841
b.tic();
3942
for ( i = 0; i < b.iterations; i++ ) {
40-
x = ( randu()*100.0 ) - 0.0;
41-
y = ( randu()*100.0 ) - 0.0;
42-
z = atan2f( x, y );
43+
z = atan2f( x[ i % x.length ], y[ i % y.length ] );
4344
if ( isnanf( z ) ) {
4445
b.fail( 'should not return NaN' );
4546
}

lib/node_modules/@stdlib/math/base/special/atan2f/benchmark/benchmark.native.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
2626
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2727
var tryRequire = require( '@stdlib/utils/try-require' );
2828
var pkg = require( './../package.json' ).name;
@@ -44,11 +44,12 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4444
var z;
4545
var i;
4646

47+
x = uniform( 100, 0.0, 100 );
48+
y = uniform( 100, 0.0, 100 );
49+
4750
b.tic();
4851
for ( i = 0; i < b.iterations; i++ ) {
49-
x = ( randu()*100.0 ) - 0.0;
50-
y = ( randu()*100.0 ) - 0.0;
51-
z = atan2f( y, x );
52+
z = atan2f( x[ i % x.length ], y[ i % y.length ] );
5253
if ( isnanf( z ) ) {
5354
b.fail( 'should not return NaN' );
5455
}

lib/node_modules/@stdlib/math/base/special/atan2f/benchmark/c/native/benchmark.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,20 @@ static float rand_float( void ) {
9191
*/
9292
static double benchmark( void ) {
9393
double elapsed;
94-
float x;
95-
float y;
94+
float x[ 100 ];
95+
float y[ 100 ];
9696
float z;
9797
double t;
9898
int i;
9999

100+
for ( i = 0; i < 100; i++ ) {
101+
x[ i ] = ( 100.0f * rand_float() ) - 0.0f;
102+
y[ i ] = ( 100.0f * rand_float() ) - 0.0f;
103+
}
104+
100105
t = tic();
101106
for ( i = 0; i < ITERATIONS; i++ ) {
102-
x = ( 100.0f * rand_float() ) - 0.0f;
103-
y = ( 100.0f * rand_float() ) - 0.0f;
104-
z = stdlib_base_atan2f( y, x );
107+
z = stdlib_base_atan2f( y[ i%100], x[ i%100] );
105108
if ( z != z ) {
106109
printf( "should not return NaN\n" );
107110
break;

lib/node_modules/@stdlib/math/base/special/atan2f/lib/main.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ var atanf = require( '@stdlib/math/base/special/atanf' );
6262
var signbitf = require( '@stdlib/number/float32/base/signbit' );
6363
var PINF = require( '@stdlib/constants/float32/pinf' );
6464
var NINF = require( '@stdlib/constants/float32/ninf' );
65-
var PI02F = require( '@stdlib/constants/float32/half-pi' );
66-
var PI04F = require( '@stdlib/constants/float32/fourth-pi' );
6765
var PI = require( '@stdlib/constants/float32/pi' );
6866

6967

@@ -116,26 +114,26 @@ function atan2f( y, x ) {
116114
if ( isinfinitef( x ) ) {
117115
if ( x === PINF ) {
118116
if ( isinfinitef( y ) ) {
119-
return copysignf( PI04F, y );
117+
return copysignf( PI/4.0, y );
120118
}
121119
return copysignf( 0.0, y );
122120
}
123121
// Case: -x = y = +infinity
124122
if ( x === NINF && y === PINF ) {
125-
return 3.0 * PI04F; // 3π/4
123+
return 3.0 * PI/4.0; // 3π/4
126124
}
127125
// Case: x = y = -infinity
128126
if ( x === NINF && y === NINF ) {
129-
return -3.0 * PI04F; // -3π/4
127+
return -3.0 * PI/4.0; // -3π/4
130128
}
131129
// Case: x is -Infinity
132130
if ( isinfinitef( y ) ) {
133-
return copysignf( 3.0 * PI04F, y );
131+
return copysignf( 3.0 * PI/4.0, y );
134132
}
135133
return copysignf( PI, y );
136134
}
137135
if ( isinfinitef( y ) ) {
138-
return copysignf( PI02F, y );
136+
return copysignf( PI/2.0, y );
139137
}
140138
if ( y === 0.0 ) {
141139
if ( x >= 0.0 && !signbitf( x ) ) {
@@ -144,7 +142,7 @@ function atan2f( y, x ) {
144142
return copysignf( PI, y );
145143
}
146144
if ( x === 0.0 ) {
147-
return copysignf( PI02F, y );
145+
return copysignf( PI/2.0, y );
148146
}
149147
q = atanf( y / x );
150148
if ( x < 0.0 ) {

lib/node_modules/@stdlib/math/base/special/atan2f/lib/native.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,31 @@ var addon = require( './../src/addon.node' );
3535
* // returns ~0.785
3636
*
3737
* @example
38-
* v = atan2f( 6.0, 2.0 ); // => atanf(3.0)
38+
* var v = atan2f( 6.0, 2.0 ); // => atanf(3.0)
3939
* // returns ~1.249
4040
*
4141
* @example
42-
* v = atan2f( 3.0, 0.0 ); // => π/2
42+
* var v = atan2f( -1.0, -1.0 ); // => atanf(1.0) - π
43+
* // returns ~-2.356
44+
*
45+
* @example
46+
* var v = atan2f( 3.0, 0.0 ); // => π/2
4347
* // returns ~1.571
4448
*
4549
* @example
46-
* v = atan2f( 3.0, NaN );
50+
* var v = atan2f( -2.0, 0.0 ); // => -π/2
51+
* // returns ~-1.571
52+
*
53+
* @example
54+
* var v = atan2f( 0.0, 0.0 );
55+
* // returns 0.0
56+
*
57+
* @example
58+
* var v = atan2f( 3.0, NaN );
59+
* // returns NaN
60+
*
61+
* @example
62+
* var v = atan2f( NaN, 2.0 );
4763
* // returns NaN
4864
*/
4965
function atan2f( y, x ) {

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
"@stdlib/number/float32/base/signbit",
4343
"@stdlib/math/base/assert/is-nanf",
4444
"@stdlib/math/base/special/atanf",
45-
"@stdlib/constants/float32/half-pi",
46-
"@stdlib/constants/float32/fourth-pi",
4745
"@stdlib/constants/float32/pinf",
4846
"@stdlib/constants/float32/ninf",
4947
"@stdlib/constants/float32/pi"
@@ -65,8 +63,6 @@
6563
"@stdlib/number/float32/base/signbit",
6664
"@stdlib/math/base/assert/is-nanf",
6765
"@stdlib/math/base/special/atanf",
68-
"@stdlib/constants/float32/half-pi",
69-
"@stdlib/constants/float32/fourth-pi",
7066
"@stdlib/constants/float32/pinf",
7167
"@stdlib/constants/float32/ninf",
7268
"@stdlib/constants/float32/pi"
@@ -88,8 +84,6 @@
8884
"@stdlib/number/float32/base/signbit",
8985
"@stdlib/math/base/assert/is-nanf",
9086
"@stdlib/math/base/special/atanf",
91-
"@stdlib/constants/float32/half-pi",
92-
"@stdlib/constants/float32/fourth-pi",
9387
"@stdlib/constants/float32/pinf",
9488
"@stdlib/constants/float32/ninf",
9589
"@stdlib/constants/float32/pi"

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
#include "stdlib/number/float32/base/signbit.h"
3737
#include "stdlib/math/base/assert/is_nanf.h"
3838
#include "stdlib/math/base/special/atanf.h"
39-
#include "stdlib/constants/float32/half_pi.h"
40-
#include "stdlib/constants/float32/fourth_pi.h"
4139
#include "stdlib/constants/float32/pinf.h"
4240
#include "stdlib/constants/float32/ninf.h"
4341
#include "stdlib/constants/float32/pi.h"
@@ -91,18 +89,18 @@ float stdlib_base_atan2f( const float y, const float x ) {
9189
if ( stdlib_base_is_infinitef( x ) ) {
9290
if ( x == STDLIB_CONSTANT_FLOAT32_PINF ) {
9391
if ( stdlib_base_is_infinitef( y ) ) {
94-
return stdlib_base_copysignf( STDLIB_CONSTANT_FLOAT32_FOURTH_PI, y );
92+
return stdlib_base_copysignf( STDLIB_CONSTANT_FLOAT32_PI / 4.0f, y );
9593
}
9694
return stdlib_base_copysignf( 0.0f, y );
9795
}
9896
// case x is -Infinity
9997
if ( stdlib_base_is_infinitef( y ) ) {
100-
return stdlib_base_copysignf( 3.0f * STDLIB_CONSTANT_FLOAT32_FOURTH_PI, y );
98+
return stdlib_base_copysignf( 3.0f * STDLIB_CONSTANT_FLOAT32_PI / 4.0f, y );
10199
}
102100
return stdlib_base_copysignf( STDLIB_CONSTANT_FLOAT32_PI, y );
103101
}
104102
if ( stdlib_base_is_infinitef( y ) ) {
105-
return stdlib_base_copysignf( STDLIB_CONSTANT_FLOAT32_HALF_PI, y );
103+
return stdlib_base_copysignf( STDLIB_CONSTANT_FLOAT32_PI / 2.0f, y );
106104
}
107105
if ( y == 0.0f ) {
108106
if ( x >= 0.0f && !stdlib_base_float32_signbit( x ) ) {
@@ -111,7 +109,7 @@ float stdlib_base_atan2f( const float y, const float x ) {
111109
return stdlib_base_copysignf( STDLIB_CONSTANT_FLOAT32_PI, y );
112110
}
113111
if ( x == 0.0f ) {
114-
return stdlib_base_copysignf( STDLIB_CONSTANT_FLOAT32_HALF_PI, y );
112+
return stdlib_base_copysignf( STDLIB_CONSTANT_FLOAT32_PI / 2.0f, y );
115113
}
116114
q = stdlib_base_atanf( y / x );
117115
if ( x < 0.0f ) {

lib/node_modules/@stdlib/math/base/special/atan2f/test/test.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ var absf = require( '@stdlib/math/base/special/absf' );
2828
var EPS = require( '@stdlib/constants/float32/eps' );
2929
var PINF = require( '@stdlib/constants/float32/pinf' );
3030
var NINF = require( '@stdlib/constants/float32/ninf' );
31-
var PI02F = require( '@stdlib/constants/float32/half-pi' );
32-
var PI04F = require( '@stdlib/constants/float32/fourth-pi' );
3331
var PI = require( '@stdlib/constants/float32/pi' );
3432
var atan2f = require( './../lib' );
3533

@@ -97,22 +95,22 @@ tape( 'the function returns `-PI` if provided `y = -0.0` and `x <= -0.0`', funct
9795
});
9896

9997
tape( 'the function returns `+PI/4` if provided `x = y = +infinity`', function test( t ) {
100-
t.equal( atan2f( PINF, PINF ), +PI04F, 'returns +PI/4' );
98+
t.equal( atan2f( PINF, PINF ), +PI/4.0, 'returns +PI/4' );
10199
t.end();
102100
});
103101

104102
tape( 'the function returns `-PI/4` if provided `x = -y = +infinity`', function test( t ) {
105-
t.equal( atan2f( NINF, PINF ), -PI04F, 'returns -PI/4' );
103+
t.equal( atan2f( NINF, PINF ), -PI/4.0, 'returns -PI/4' );
106104
t.end();
107105
});
108106

109107
tape( 'the function returns `*3*PI/4` if provided `-x = y = +infinity`', function test( t ) {
110-
t.equal( atan2f( PINF, NINF ), +3.0*PI04F, 'returns +3*PI/4' );
108+
t.equal( atan2f( PINF, NINF ), +3.0*PI/4.0, 'returns +3*PI/4' );
111109
t.end();
112110
});
113111

114112
tape( 'the function returns `-3*PI/4` if provided `x = y = -infinity`', function test( t ) {
115-
t.equal( atan2f( NINF, NINF ), -3.0*PI04F, 'returns -3*PI/4' );
113+
t.equal( atan2f( NINF, NINF ), -3.0*PI/4.0, 'returns -3*PI/4' );
116114
t.end();
117115
});
118116

@@ -145,23 +143,23 @@ tape( 'the function returns `+PI/2` when `y = +infinity`', function test( t ) {
145143
});
146144

147145
tape( 'the function returns `-PI/2` when `y = -infinity`', function test( t ) {
148-
t.equal( atan2f( NINF, -1.0 ), -PI02F, 'returns -PI/2' );
149-
t.equal( atan2f( NINF, 0.0 ), -PI02F, 'returns -PI/2' );
150-
t.equal( atan2f( NINF, 2.0 ), -PI02F, 'returns -PI/2' );
146+
t.equal( atan2f( NINF, -1.0 ), -PI/2.0, 'returns -PI/2' );
147+
t.equal( atan2f( NINF, 0.0 ), -PI/2.0, 'returns -PI/2' );
148+
t.equal( atan2f( NINF, 2.0 ), -PI/2.0, 'returns -PI/2' );
151149
t.end();
152150
});
153151

154152
tape( 'the function returns `PI/2` if provided a positive `y` and `x=0`', function test( t ) {
155-
t.equal( atan2f( 2.0, 0.0 ), PI02F, 'returns PI/2' );
156-
t.equal( atan2f( 1.0, 0.0 ), PI02F, 'returns PI/2' );
157-
t.equal( atan2f( 0.5, 0.0 ), PI02F, 'returns PI/2' );
153+
t.equal( atan2f( 2.0, 0.0 ), PI/2.0, 'returns PI/2' );
154+
t.equal( atan2f( 1.0, 0.0 ), PI/2.0, 'returns PI/2' );
155+
t.equal( atan2f( 0.5, 0.0 ), PI/2.0, 'returns PI/2' );
158156
t.end();
159157
});
160158

161159
tape( 'the function returns `-PI/2` if provided a negative `y` and `x=0`', function test( t ) {
162-
t.equal( atan2f( -2.0, 0.0 ), -PI02F, 'returns PI/2' );
163-
t.equal( atan2f( -1.0, 0.0 ), -PI02F, 'returns PI/2' );
164-
t.equal( atan2f( -0.5, 0.0 ), -PI02F, 'returns PI/2' );
160+
t.equal( atan2f( -2.0, 0.0 ), -PI/2.0, 'returns PI/2' );
161+
t.equal( atan2f( -1.0, 0.0 ), -PI/2.0, 'returns PI/2' );
162+
t.equal( atan2f( -0.5, 0.0 ), -PI/2.0, 'returns PI/2' );
165163
t.end();
166164
});
167165

@@ -179,7 +177,7 @@ tape( 'the function evaluates the `atan2f` function (when x and y are positive)'
179177
for ( i = 0; i < x.length; i++ ) {
180178
actual = atan2f( y[i], x[i] );
181179
delta = absf( actual - expected[i] );
182-
tol = 2.0 * EPS * absf( expected[i] );
180+
tol = 3.0 * EPS * absf( expected[i] );
183181
t.equal( delta <= tol, true, 'within tolerance. y: '+y[i]+'. x: '+x[i]+'. Actual: '+actual+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' );
184182
}
185183
t.end();

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

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ var tryRequire = require( '@stdlib/utils/try-require' );
3030
var EPS = require( '@stdlib/constants/float32/eps' );
3131
var PINF = require( '@stdlib/constants/float32/pinf' );
3232
var NINF = require( '@stdlib/constants/float32/ninf' );
33-
var PI02F = require( '@stdlib/constants/float32/half-pi' );
34-
var PI04F = require( '@stdlib/constants/float32/fourth-pi' );
3533
var PI = require( '@stdlib/constants/float32/pi' );
3634

3735

@@ -106,22 +104,22 @@ tape( 'the function returns `-PI` if provided `y = -0.0` and `x <= -0.0`', opts,
106104
});
107105

108106
tape( 'the function returns `+PI/4` if provided `x = y = +infinity`', opts, function test( t ) {
109-
t.equal( atan2f( PINF, PINF ), +PI04F, 'returns +PI/4' );
107+
t.equal( atan2f( PINF, PINF ), +PI/4.0, 'returns +PI/4' );
110108
t.end();
111109
});
112110

113111
tape( 'the function returns `-PI/4` if provided `x = -y = +infinity`', opts, function test( t ) {
114-
t.equal( atan2f( NINF, PINF ), -PI04F, 'returns -PI/4' );
112+
t.equal( atan2f( NINF, PINF ), -PI/4.0, 'returns -PI/4' );
115113
t.end();
116114
});
117115

118116
tape( 'the function returns `*3*PI/4` if provided `-x = y = +infinity`', opts, function test( t ) {
119-
t.equal( atan2f( PINF, NINF ), +3.0*PI04F, 'returns +3*PI/4' );
117+
t.equal( atan2f( PINF, NINF ), +3.0*PI/4.0, 'returns +3*PI/4' );
120118
t.end();
121119
});
122120

123121
tape( 'the function returns `-3*PI/4` if provided `x = y = -infinity`', opts, function test( t ) {
124-
t.equal( atan2f( NINF, NINF ), -3.0*PI04F, 'returns -3*PI/4' );
122+
t.equal( atan2f( NINF, NINF ), -3.0*PI/4.0, 'returns -3*PI/4' );
125123
t.end();
126124
});
127125

@@ -154,23 +152,23 @@ tape( 'the function returns `+PI/2` when `y = +infinity`', opts, function test(
154152
});
155153

156154
tape( 'the function returns `-PI/2` when `y = -infinity`', opts, function test( t ) {
157-
t.equal( atan2f( NINF, -1.0 ), -PI02F, 'returns -PI/2' );
158-
t.equal( atan2f( NINF, 0.0 ), -PI02F, 'returns -PI/2' );
159-
t.equal( atan2f( NINF, 2.0 ), -PI02F, 'returns -PI/2' );
155+
t.equal( atan2f( NINF, -1.0 ), -PI/2.0, 'returns -PI/2' );
156+
t.equal( atan2f( NINF, 0.0 ), -PI/2.0, 'returns -PI/2' );
157+
t.equal( atan2f( NINF, 2.0 ), -PI/2.0, 'returns -PI/2' );
160158
t.end();
161159
});
162160

163161
tape( 'the function returns `PI/2` if provided a positive `y` and `x=0`', opts, function test( t ) {
164-
t.equal( atan2f( 2.0, 0.0 ), PI02F, 'returns PI/2' );
165-
t.equal( atan2f( 1.0, 0.0 ), PI02F, 'returns PI/2' );
166-
t.equal( atan2f( 0.5, 0.0 ), PI02F, 'returns PI/2' );
162+
t.equal( atan2f( 2.0, 0.0 ), PI/2.0, 'returns PI/2' );
163+
t.equal( atan2f( 1.0, 0.0 ), PI/2.0, 'returns PI/2' );
164+
t.equal( atan2f( 0.5, 0.0 ), PI/2.0, 'returns PI/2' );
167165
t.end();
168166
});
169167

170168
tape( 'the function returns `-PI/2` if provided a negative `y` and `x=0`', opts, function test( t ) {
171-
t.equal( atan2f( -2.0, 0.0 ), -PI02F, 'returns PI/2' );
172-
t.equal( atan2f( -1.0, 0.0 ), -PI02F, 'returns PI/2' );
173-
t.equal( atan2f( -0.5, 0.0 ), -PI02F, 'returns PI/2' );
169+
t.equal( atan2f( -2.0, 0.0 ), -PI/2.0, 'returns PI/2' );
170+
t.equal( atan2f( -1.0, 0.0 ), -PI/2.0, 'returns PI/2' );
171+
t.equal( atan2f( -0.5, 0.0 ), -PI/2.0, 'returns PI/2' );
174172
t.end();
175173
});
176174

0 commit comments

Comments
 (0)