diff --git a/lib/node_modules/@stdlib/math/base/special/pow/include/stdlib/math/base/special/pow.h b/lib/node_modules/@stdlib/math/base/special/pow/include/stdlib/math/base/special/pow.h index 5fddb2ea091f..af068394e9ba 100644 --- a/lib/node_modules/@stdlib/math/base/special/pow/include/stdlib/math/base/special/pow.h +++ b/lib/node_modules/@stdlib/math/base/special/pow/include/stdlib/math/base/special/pow.h @@ -29,7 +29,7 @@ extern "C" { /** * Evaluates the exponential function. */ -double stdlib_base_pow( const double base, const double exponent ); +double stdlib_base_pow( const double x, const double y ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/math/base/special/pow/lib/log2ax.js b/lib/node_modules/@stdlib/math/base/special/pow/lib/log2ax.js index 3eed8c363dce..392d4bb2ea90 100644 --- a/lib/node_modules/@stdlib/math/base/special/pow/lib/log2ax.js +++ b/lib/node_modules/@stdlib/math/base/special/pow/lib/log2ax.js @@ -38,6 +38,7 @@ var getHighWord = require( '@stdlib/number/float64/base/get-high-word' ); var setLowWord = require( '@stdlib/number/float64/base/set-low-word' ); var setHighWord = require( '@stdlib/number/float64/base/set-high-word' ); var BIAS = require( '@stdlib/constants/float64/exponent-bias' ); +var HIGH_NUM_SIGNIFICAND_BITS = require( '@stdlib/constants/float64/num-high-word-significand-bits' ); var polyvalL = require( './polyval_l.js' ); @@ -58,9 +59,6 @@ var HIGH_BIASED_EXP_NEG_512 = 0x20000000|0; // asm type annotation // 0x00080000 = 524288 => 0 00000000000 10000000000000000000 var HIGH_SIGNIFICAND_HALF = 0x00080000|0; // asm type annotation -// TODO: consider making an external constant -var HIGH_NUM_SIGNIFICAND_BITS = 20|0; // asm type annotation - var TWO53 = 9007199254740992.0; // 0x43400000, 0x00000000 // 2/(3*LN2) diff --git a/lib/node_modules/@stdlib/math/base/special/pow/lib/pow2.js b/lib/node_modules/@stdlib/math/base/special/pow/lib/pow2.js index 79d27e337bd8..378e9da67b6a 100644 --- a/lib/node_modules/@stdlib/math/base/special/pow/lib/pow2.js +++ b/lib/node_modules/@stdlib/math/base/special/pow/lib/pow2.js @@ -43,6 +43,7 @@ var LN2 = require( '@stdlib/constants/float64/ln-two' ); var BIAS = require( '@stdlib/constants/float64/exponent-bias' ); var ABS_MASK = require( '@stdlib/constants/float64/high-word-abs-mask' ); var HIGH_SIGNIFICAND_MASK = require( '@stdlib/constants/float64/high-word-significand-mask' ); +var HIGH_NUM_SIGNIFICAND_BITS = require( '@stdlib/constants/float64/num-high-word-significand-bits' ); var polyvalP = require( './polyval_p.js' ); @@ -54,9 +55,6 @@ var HIGH_MIN_NORMAL_EXP = 0x00100000|0; // asm type annotation // 0x3fe00000 = 1071644672 => 0 01111111110 00000000000000000000 => biased exponent: 1022 = -1+1023 => 2^-1 var HIGH_BIASED_EXP_NEG_1 = 0x3fe00000|0; // asm type annotation -// TODO: consider making into an external constant -var HIGH_NUM_SIGNIFICAND_BITS = 20|0; // asm type annotation - // High: LN2 var LN2_HI = 6.93147182464599609375e-01; // 0x3FE62E43, 0x00000000 diff --git a/lib/node_modules/@stdlib/math/base/special/pow/manifest.json b/lib/node_modules/@stdlib/math/base/special/pow/manifest.json index e466fe9a877a..317d41fb746c 100644 --- a/lib/node_modules/@stdlib/math/base/special/pow/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/pow/manifest.json @@ -54,7 +54,8 @@ "@stdlib/math/base/assert/is-infinite", "@stdlib/math/base/assert/is-integer", "@stdlib/math/base/special/sqrt", - "@stdlib/number/float64/base/to-words" + "@stdlib/number/float64/base/to-words", + "@stdlib/constants/float64/num-high-word-significand-bits" ] }, { @@ -85,7 +86,8 @@ "@stdlib/math/base/assert/is-infinite", "@stdlib/math/base/assert/is-integer", "@stdlib/math/base/special/sqrt", - "@stdlib/number/float64/base/to-words" + "@stdlib/number/float64/base/to-words", + "@stdlib/constants/float64/num-high-word-significand-bits" ] }, { @@ -116,7 +118,8 @@ "@stdlib/math/base/assert/is-infinite", "@stdlib/math/base/assert/is-integer", "@stdlib/math/base/special/sqrt", - "@stdlib/number/float64/base/to-words" + "@stdlib/number/float64/base/to-words", + "@stdlib/constants/float64/num-high-word-significand-bits" ] } ] diff --git a/lib/node_modules/@stdlib/math/base/special/pow/src/main.c b/lib/node_modules/@stdlib/math/base/special/pow/src/main.c index 29360167b486..82ce2c70ff0b 100644 --- a/lib/node_modules/@stdlib/math/base/special/pow/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/pow/src/main.c @@ -14,6 +14,20 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. +* +* +* ## Notice +* +* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/s_pow.c}. The implementation follows the original, but has been modified for JavaScript. +* +* ```text +* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. +* +* Developed at SunPro, a Sun Microsystems, Inc. business. +* Permission to use, copy, modify, and distribute this +* software is freely granted, provided that this notice +* is preserved. +* ``` */ #include "stdlib/math/base/special/pow.h" @@ -35,6 +49,7 @@ #include "stdlib/math/base/assert/is_integer.h" #include "stdlib/math/base/special/sqrt.h" #include "stdlib/number/float64/base/to_words.h" +#include "stdlib/constants/float64/num_high_word_significand_bits.h" // 0x3fefffff = 1072693247 => 0 01111111110 11111111111111111111 => biased exponent: 1022 = -1+1023 => 2^-1 static const int32_t HIGH_MAX_NEAR_UNITY = 0x3fefffff; @@ -49,9 +64,6 @@ static const int32_t HIGH_MIN_NORMAL_EXP = 0x00100000; // 0x3fe00000 = 1071644672 => 0 01111111110 00000000000000000000 => biased exponent: 1022 = -1+1023 => 2^-1 static const int32_t HIGH_BIASED_EXP_NEG_1 = 0x3fe00000; -// TODO: consider making into an external constant -static const int32_t HIGH_NUM_SIGNIFICAND_BITS = 20; - // High: LN2 static const double LN2_HI = 6.93147182464599609375e-01; // 0x3FE62E43, 0x00000000 @@ -316,18 +328,18 @@ static double pow2( uint32_t j, const double hp, const double lp ) { hpc = hp; jc = (int32_t)j; i = ( j & STDLIB_CONSTANT_FLOAT64_HIGH_WORD_ABS_MASK ); - k = ( ( i >> HIGH_NUM_SIGNIFICAND_BITS ) - STDLIB_CONSTANT_FLOAT64_EXPONENT_BIAS ); + k = ( ( i >> STDLIB_CONSTANT_FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS ) - STDLIB_CONSTANT_FLOAT64_EXPONENT_BIAS ); n = 0; nc = (int32_t)n; // `|z| > 0.5`, set `n = z+0.5` if ( i > HIGH_BIASED_EXP_NEG_1 ) { n = ( j + ( HIGH_MIN_NORMAL_EXP >> ( k + 1 ) ) ); - k = ( ( ( n & STDLIB_CONSTANT_FLOAT64_HIGH_WORD_ABS_MASK ) >> HIGH_NUM_SIGNIFICAND_BITS ) - STDLIB_CONSTANT_FLOAT64_EXPONENT_BIAS ); // new k for n + k = ( ( ( n & STDLIB_CONSTANT_FLOAT64_HIGH_WORD_ABS_MASK ) >> STDLIB_CONSTANT_FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS ) - STDLIB_CONSTANT_FLOAT64_EXPONENT_BIAS ); // new k for n tmp = ( ( n & ~( HIGH_SIGNIFICAND_MASK >> k ) ) ); t = 0.0; stdlib_base_float64_set_high_word( tmp, &t ); - n = ( ( ( n & HIGH_SIGNIFICAND_MASK ) | HIGH_MIN_NORMAL_EXP ) >> ( HIGH_NUM_SIGNIFICAND_BITS - k ) ); + n = ( ( ( n & HIGH_SIGNIFICAND_MASK ) | HIGH_MIN_NORMAL_EXP ) >> ( STDLIB_CONSTANT_FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS - k ) ); nc = (int32_t)n; if ( jc < 0 ) { nc = -nc; @@ -345,11 +357,11 @@ static double pow2( uint32_t j, const double hp, const double lp ) { r = ( ( z * t1 ) / ( t1 - 2.0 ) ) - ( w + ( z * w ) ); z = 1.0 - ( r - z ); stdlib_base_float64_get_high_word( z, &j ); - j = j + ( nc << HIGH_NUM_SIGNIFICAND_BITS ); + j = j + ( nc << STDLIB_CONSTANT_FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS ); jc = (int32_t)j; // Check for subnormal output... - if ( ( jc >> HIGH_NUM_SIGNIFICAND_BITS ) <= 0 ) { + if ( ( jc >> STDLIB_CONSTANT_FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS ) <= 0 ) { z = stdlib_base_ldexp( z, nc ); } else { stdlib_base_float64_set_high_word( j, &z ); @@ -437,7 +449,7 @@ void log2ax( const double ax, const int32_t ahx, double *o1, double *o2 ) { ahxc = (int32_t)ahxcc; } // Extract the unbiased exponent of `x`: - n += ( ( ahxc >> HIGH_NUM_SIGNIFICAND_BITS ) - STDLIB_CONSTANT_FLOAT64_EXPONENT_BIAS ); + n += ( ( ahxc >> STDLIB_CONSTANT_FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS ) - STDLIB_CONSTANT_FLOAT64_EXPONENT_BIAS ); // Isolate the significand bits of `x`: j = ( ahxc & HIGH_SIGNIFICAND_MASK );