Skip to content

Commit 276b3fc

Browse files
committed
chore: not for review
1 parent b440837 commit 276b3fc

File tree

5 files changed

+210
-88
lines changed

5 files changed

+210
-88
lines changed

lib/node_modules/@stdlib/math/base/special/pow/examples/c/example.c

+11-6
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ int main( void ) {
2626
double x;
2727
int i;
2828

29-
for ( i = 0; i < 100; i++ ) {
30-
b = ( ( (double)rand() / (double)RAND_MAX ) * 10.0 );
31-
x = ( ( (double)rand() / (double)RAND_MAX ) * 10.0 ) - 5.0;
32-
out = stdlib_base_pow( b, x );
33-
printf( "pow(%lf, %lf) = %lf\n", b, x, out );
34-
}
29+
// for ( i = 0; i < 100; i++ ) {
30+
// b = ( ( (double)rand() / (double)RAND_MAX ) * 10.0 );
31+
// x = ( ( (double)rand() / (double)RAND_MAX ) * 10.0 ) - 5.0;
32+
// out = stdlib_base_pow( b, x );
33+
// printf( "pow(%lf, %lf) = %lf\n", b, x, out );
34+
// }
35+
36+
b = 1.6898381e-52;
37+
x = 5.9641240918724066;
38+
out = stdlib_base_pow( b, x );
39+
printf( "pow(%e, %lf) = %e\n", b, x, out );
3540
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
var randu = require( '@stdlib/random/base/randu' );
22+
var round = require( '@stdlib/math/base/special/round' );
23+
var pow = require( './../lib' );
24+
25+
var b;
26+
var x;
27+
var i;
28+
29+
for ( i = 0; i < 1; i++ ) {
30+
b = 1.6898381e-52;
31+
x = 5.9641240918724066;
32+
console.log( '%d^%d = %d', b, x, pow( b, x ) );
33+
}

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

+40-5
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,15 @@ function pow( x, y ) {
213213
if ( isnan( x ) || isnan( y ) ) {
214214
return NaN;
215215
}
216+
console.log('inside\n');
216217
// Split `y` into high and low words:
217218
toWords.assign( y, WORDS, 1, 0 );
218219
hy = WORDS[ 0 ];
219220
ly = WORDS[ 1 ];
220-
221+
console.log('hy: %d^ ly: %d\n', hy, ly);
221222
// Special cases `y`...
222223
if ( ly === 0 ) {
224+
console.log('inside ly==0\n');
223225
if ( y === 0.0 ) {
224226
return 1.0;
225227
}
@@ -246,36 +248,46 @@ function pow( x, y ) {
246248
return x * x;
247249
}
248250
if ( isInfinite( y ) ) {
251+
console.log('inside is-infinite\n');
249252
return yIsInfinite( x, y );
250253
}
251254
}
252255
// Split `x` into high and low words:
253256
toWords.assign( x, WORDS, 1, 0 );
254257
hx = WORDS[ 0 ];
255258
lx = WORDS[ 1 ];
259+
console.log('hx: %d^ lx: %d\n', hx, lx);
256260

257261
// Special cases `x`...
258262
if ( lx === 0 ) {
263+
console.log('lx==0\n');
259264
if ( hx === 0 ) {
265+
console.log('hx==0\n');
260266
return xIsZero( x, y );
261267
}
262268
if ( x === 1.0 ) {
269+
console.log('2\n');
263270
return 1.0;
264271
}
265272
if (
266273
x === -1.0 &&
267274
isOdd( y )
268275
) {
276+
console.log('3\n');
269277
return -1.0;
270278
}
271279
if ( isInfinite( x ) ) {
280+
console.log('4\n');
272281
if ( x === NINF ) {
282+
console.log('5\n');
273283
// `pow( 1/x, -y )`
274284
return pow( -0.0, -y );
275285
}
276286
if ( y < 0.0 ) {
287+
console.log('6\n');
277288
return 0.0;
278289
}
290+
console.log('7\n');
279291
return PINF;
280292
}
281293
}
@@ -287,55 +299,69 @@ function pow( x, y ) {
287299
return (x-x)/(x-x);
288300
}
289301
ax = abs( x );
290-
302+
console.log('ax: %d\n', ax);
291303
// Remove the sign bits (i.e., get absolute values):
292304
ahx = (hx & ABS_MASK)|0; // asm type annotation
293305
ahy = (hy & ABS_MASK)|0; // asm type annotation
294-
306+
console.log('ahx: %d^ ahy: %d\n', ahx, ahy);
295307
// Extract the sign bits:
296308
sx = (hx >>> HIGH_NUM_NONSIGN_BITS)|0; // asm type annotation
297309
sy = (hy >>> HIGH_NUM_NONSIGN_BITS)|0; // asm type annotation
298-
310+
console.log('sx: %d^ sy: %d\n', sx, sy);
311+
console.log('check_if_odd: %d\n', isOdd(y));
299312
// Determine the sign of the result...
300313
if ( sx && isOdd( y ) ) {
314+
console.log('8\n');
301315
sx = -1.0;
302316
} else {
317+
console.log('9\n');
303318
sx = 1.0;
304319
}
305320
// Case 1: `|y|` is huge...
306321

307322
// |y| > 2^31
308323
if ( ahy > HIGH_BIASED_EXP_31 ) {
324+
console.log('10\n');
309325
// `|y| > 2^64`, then must over- or underflow...
310326
if ( ahy > HIGH_BIASED_EXP_64 ) {
327+
console.log('11\n');
311328
return yIsHuge( x, y );
312329
}
313330
// Over- or underflow if `x` is not close to unity...
314331

315332
if ( ahx < HIGH_MAX_NEAR_UNITY ) {
333+
console.log('12\n');
316334
// y < 0
317335
if ( sy === 1 ) {
336+
console.log('13\n');
318337
// Signal overflow...
319338
return sx * HUGE * HUGE;
320339
}
340+
console.log('14\n');
321341
// Signal underflow...
322342
return sx * TINY * TINY;
323343
}
324344
if ( ahx > HIGH_BIASED_EXP_0 ) {
345+
console.log('15\n');
325346
// y > 0
326347
if ( sy === 0 ) {
348+
console.log('16\n');
327349
// Signal overflow...
328350
return sx * HUGE * HUGE;
329351
}
352+
console.log('17\n');
330353
// Signal underflow...
331354
return sx * TINY * TINY;
332355
}
356+
console.log('18\n');
333357
// At this point, `|1-x|` is tiny (`<= 2^-20`). Suffice to compute `log(x)` by `x - x^2/2 + x^3/3 - x^4/4`.
334358
t = logx( LOG_WORKSPACE, ax );
335359
}
336360
// Case 2: `|y|` is not huge...
337361
else {
362+
console.log('19\n');
338363
t = log2ax( LOG_WORKSPACE, ax, ahx );
364+
console.log('ax: %d, ahx: %d\n', ax, ahx);
339365
}
340366
// Split `y` into `y1 + y2` and compute `(y1+y2) * (t1+t2)`...
341367
y1 = setLowWord( y, 0 );
@@ -350,31 +376,40 @@ function pow( x, y ) {
350376

351377
// z >= 1024
352378
if ( j >= HIGH_BIASED_EXP_10 ) {
379+
console.log('20\n');
353380
// z > 1024
354381
if ( ((j-HIGH_BIASED_EXP_10)|i) !== 0 ) {
382+
console.log('21\n');
355383
// Signal overflow...
356384
return sx * HUGE * HUGE;
357385
}
386+
console.log('22\n');
358387
if ( (lp+OVT) > (z-hp) ) {
388+
console.log('23\n');
359389
// Signal overflow...
360390
return sx * HUGE * HUGE;
361391
}
362392
}
363393
// z <= -1075
364394
else if ( (j&ABS_MASK) >= HIGH_1075 ) {
395+
console.log('24\n');
365396
// z < -1075
366397
if ( ((j-HIGH_NEG_1075)|i) !== 0 ) {
398+
console.log('25\n');
367399
// Signal underflow...
368400
return sx * TINY * TINY;
369401
}
370402
if ( lp <= (z-hp) ) {
403+
console.log('26\n');
371404
// Signal underflow...
372405
return sx * TINY * TINY;
373406
}
374407
}
408+
console.log('27\n');
375409
// Compute `2^(hp+lp)`...
376410
z = pow2( j, hp, lp );
377-
411+
console.log('%d^%d', z, sx);
412+
console.log('28\n');
378413
return sx * z;
379414
}
380415

lib/node_modules/@stdlib/math/base/special/pow/src/addon.c

-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@
1919
#include "stdlib/math/base/special/pow.h"
2020
#include "stdlib/math/base/napi/binary.h"
2121

22-
// cppcheck-suppress shadowFunction
2322
STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_pow )

0 commit comments

Comments
 (0)