From 63a9a5ab16c38ab67543b599cb9d1062002f265a Mon Sep 17 00:00:00 2001 From: Pranav <85227306+Pranavchiku@users.noreply.github.com> Date: Wed, 6 Mar 2024 11:17:55 +0530 Subject: [PATCH] chore: apply suggestions from code review Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com> --- .../special/log2/benchmark/c/native/benchmark.c | 2 +- .../@stdlib/math/base/special/log2/lib/native.js | 2 +- .../math/base/special/log2/lib/polyval_p.js | 2 +- .../math/base/special/log2/lib/polyval_q.js | 2 +- .../@stdlib/math/base/special/log2/src/main.c | 16 ++++++++-------- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/log2/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/log2/benchmark/c/native/benchmark.c index 2552f7bb49b..be670cb58dc 100644 --- a/lib/node_modules/@stdlib/math/base/special/log2/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/log2/benchmark/c/native/benchmark.c @@ -101,7 +101,7 @@ double benchmark() { t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = rand_double(); + x = ( 1000.0*rand_double() ) - 0.0; y = stdlib_base_log2( x ); if ( y != y ) { printf( "should not return NaN\n" ); diff --git a/lib/node_modules/@stdlib/math/base/special/log2/lib/native.js b/lib/node_modules/@stdlib/math/base/special/log2/lib/native.js index dd09886f51b..0b06a313f3d 100644 --- a/lib/node_modules/@stdlib/math/base/special/log2/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/log2/lib/native.js @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Evaluate the binary logarithm. +* Evaluates the binary logarithm. * * @private * @param {number} x - input value diff --git a/lib/node_modules/@stdlib/math/base/special/log2/lib/polyval_p.js b/lib/node_modules/@stdlib/math/base/special/log2/lib/polyval_p.js index 6a1309b25ee..520e03fbd35 100644 --- a/lib/node_modules/@stdlib/math/base/special/log2/lib/polyval_p.js +++ b/lib/node_modules/@stdlib/math/base/special/log2/lib/polyval_p.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2022 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/log2/lib/polyval_q.js b/lib/node_modules/@stdlib/math/base/special/log2/lib/polyval_q.js index 31521f3110d..fb83e6c31d9 100644 --- a/lib/node_modules/@stdlib/math/base/special/log2/lib/polyval_q.js +++ b/lib/node_modules/@stdlib/math/base/special/log2/lib/polyval_q.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2022 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/log2/src/main.c b/lib/node_modules/@stdlib/math/base/special/log2/src/main.c index ed5d17eeed9..5183b6ebc56 100644 --- a/lib/node_modules/@stdlib/math/base/special/log2/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/log2/src/main.c @@ -131,16 +131,16 @@ static double polyval_q( const double x ) { * @return output value */ double klog( const double x ) { + double hfsq; uint32_t hx; int32_t i; int32_t j; - double hfsq; double t1; double t2; double f; + double R; double s; double z; - double R; double w; stdlib_base_float64_get_high_word( x, &hx ); @@ -178,11 +178,11 @@ double klog( const double x ) { double stdlib_base_log2( const double x ) { uint32_t hx; uint32_t lx; + double hi; int32_t i; int32_t k; - double xc; - double hi; double lo; + double xc; double f; xc = x; @@ -196,7 +196,7 @@ double stdlib_base_log2( const double x ) { if ( ( ( hx & STDLIB_CONSTANT_FLOAT64_HIGH_WORD_ABS_MASK ) | lx ) == 0 ) { return STDLIB_CONSTANT_FLOAT64_NINF; } - k -= 54; // asm type annotation + k -= 54; // Subnormal number, scale up x: xc *= TWO54; @@ -205,13 +205,13 @@ double stdlib_base_log2( const double x ) { if ( hx >= HIGH_MAX_NORMAL_EXP ) { return xc + xc; } - k += ( ( hx>>20 ) - STDLIB_CONSTANT_FLOAT64_EXPONENT_BIAS ); // asm type annotation + k += ( ( hx>>20 ) - STDLIB_CONSTANT_FLOAT64_EXPONENT_BIAS ); hx &= HIGH_SIGNIFICAND_MASK; - i = ( ( hx + 0x95f64 ) & 0x100000 ); // asm type annotation + i = ( ( hx + 0x95f64 ) & 0x100000 ); // Normalize x or x/2... stdlib_base_float64_set_high_word( hx|( i^HIGH_BIASED_EXP_0 ), &xc ); - k += (i>>20); // asm type annotation + k += (i>>20); f = klog( xc ); xc -= 1; stdlib_base_float64_set_low_word( xc, &hi );