File tree Expand file tree Collapse file tree 3 files changed +16
-12
lines changed
lib/node_modules/@stdlib/math/base/special/atan2f Expand file tree Collapse file tree 3 files changed +16
-12
lines changed Original file line number Diff line number Diff line change 5858var isinfinitef = require ( '@stdlib/math/base/assert/is-infinitef' ) ;
5959var isnanf = require ( '@stdlib/math/base/assert/is-nanf' ) ;
6060var copysignf = require ( '@stdlib/math/base/special/copysignf' ) ;
61+ var float64ToFloat32 = require ( '@stdlib/number/float64/base/to-float32' ) ;
6162var atanf = require ( '@stdlib/math/base/special/atanf' ) ;
6263var signbitf = require ( '@stdlib/number/float32/base/signbit' ) ;
6364var PINF = require ( '@stdlib/constants/float32/pinf' ) ;
@@ -120,18 +121,15 @@ function atan2f( y, x ) {
120121 }
121122 return copysignf ( 0.0 , y ) ;
122123 }
123- // Case: -x = y = +infinity
124- if ( x === NINF && y === PINF ) {
124+ }
125+ // Case: x is -Infinity
126+ if ( x === NINF ) {
127+ if ( y === PINF ) {
125128 return 3.0 * PI04F ; // 3π/4
126129 }
127- // Case: x = y = -infinity
128- if ( x === NINF && y === NINF ) {
130+ if ( y === NINF ) {
129131 return - 3.0 * PI04F ; // -3π/4
130132 }
131- // Case: x is -Infinity
132- if ( isinfinitef ( y ) ) {
133- return copysignf ( 3.0 * PI04F , y ) ;
134- }
135133 return copysignf ( PI , y ) ;
136134 }
137135 if ( isinfinitef ( y ) ) {
Original file line number Diff line number Diff line change 3838#include "stdlib/constants/float32/half_pi.h"
3939#include "stdlib/constants/float32/fourth_pi.h"
4040#include "stdlib/constants/float32/pinf.h"
41+ #include "stdlib/constants/float32/ninf.h"
4142#include "stdlib/constants/float32/pi.h"
4243#include <stdint.h>
4344
@@ -95,10 +96,15 @@ float stdlib_base_atan2f( const float y, const float x ) {
9596 return stdlib_base_copysignf ( 0.0f , y );
9697 }
9798 // Case: x is -Infinity
98- if ( stdlib_base_is_infinitef ( y ) ) {
99- return stdlib_base_copysignf ( 3.0f * STDLIB_CONSTANT_FLOAT32_FOURTH_PI , y );
99+ if ( x == STDLIB_CONSTANT_FLOAT32_NINF ) {
100+ if ( y == STDLIB_CONSTANT_FLOAT32_PINF ) {
101+ return 3.0f * STDLIB_CONSTANT_FLOAT32_FOURTH_PI ; // 3π/4
102+ }
103+ if ( y == STDLIB_CONSTANT_FLOAT32_NINF ) {
104+ return -3.0f * STDLIB_CONSTANT_FLOAT32_FOURTH_PI ; // -3π/4
105+ }
106+ return stdlib_base_copysignf ( STDLIB_CONSTANT_FLOAT32_PI , y );
100107 }
101- return stdlib_base_copysignf ( STDLIB_CONSTANT_FLOAT32_PI , y );
102108 }
103109 if ( stdlib_base_is_infinitef ( y ) ) {
104110 return stdlib_base_copysignf ( STDLIB_CONSTANT_FLOAT32_HALF_PI , y );
Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ tape( 'the function evaluates the `atan2f` function (when x and y are positive)'
188188 for ( i = 0 ; i < x . length ; i ++ ) {
189189 actual = atan2f ( y [ i ] , x [ i ] ) ;
190190 delta = absf ( actual - expected [ i ] ) ;
191- tol = 2 .0 * EPS * absf ( expected [ i ] ) ;
191+ tol = 1 .0 * EPS * absf ( expected [ i ] ) ;
192192 t . equal ( delta <= tol , true , 'within tolerance. y: ' + y [ i ] + '. x: ' + x [ i ] + '. Actual: ' + actual + '. E: ' + expected [ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' ) ;
193193 }
194194 t . end ( ) ;
You can’t perform that action at this time.
0 commit comments