Skip to content
Closed
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
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Mohammad Kaif <[email protected]>
Momtchil Momtchev <[email protected]>
Muhammad Haris <[email protected]>
Naresh Jagadeesan <[email protected]>
Neeraj Pathak <[email protected]>
NightKnight <[email protected]>
Nithin Katta <[email protected]>
Nourhan Hasan <[email protected]>
Expand Down
18 changes: 11 additions & 7 deletions lib/node_modules/@stdlib/math/base/special/atanh/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,24 @@ static const double NEAR_ZERO = 1.0 / (1 << 28); // 2**-28
* out = stdlib_base_atanh( 0.9 );
* // returns ~1.472
*/

static const double one = 1.0;
static const double zero = 0.0;

double stdlib_base_atanh( const double x ) {
int32_t sgn;
double ax;
double t;
if ( stdlib_base_is_nan( x ) || x < -1.0 || x > 1.0 ) {
return 0.0 / 0.0; // NaN
if ( stdlib_base_is_nan( x ) || x < -one || x > one ) {
return zero / zero ; // NaN
}
if ( x == 1.0 ) {
if ( x === one ) {
return STDLIB_CONSTANT_FLOAT64_PINF;
}
if ( x == -1.0 ) {
if ( x == -one ) {
return STDLIB_CONSTANT_FLOAT64_NINF;
}
if ( x < 0.0 ) {
if ( x < zero ) {
sgn = 1;
ax = -x;
} else {
Expand All @@ -104,9 +108,9 @@ double stdlib_base_atanh( const double x ) {
}
if ( ax < 0.5 ) {
t = ax + ax;
t = 0.5 * stdlib_base_log1p( t + ( t * ax / ( 1 - ax ) ) );
t = 0.5 * stdlib_base_log1p( t + ( t * ax / ( one - ax ) ) );
} else {
t = 0.5 * stdlib_base_log1p( ( ax + ax ) / ( 1 - ax ) );
t = 0.5 * stdlib_base_log1p( ( ax + ax ) / ( one - ax ) );
}
return ( sgn == 1 ) ? -t : t;
}
Loading