Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Jun 10, 2024
1 parent 3704ecf commit 298c890
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4464,6 +4464,7 @@ A total of 26 people contributed to this release. Thank you to the following con

<details>

- [`fb04f19`](https://github.com/stdlib-js/stdlib/commit/fb04f1968006f8bee36735f9b71d857f478bb6c1) - **refactor:** reduce test tolerance and fix casting [(#2356)](https://github.com/stdlib-js/stdlib/pull/2356) _(by Gunj Joshi)_
- [`ced30b0`](https://github.com/stdlib-js/stdlib/commit/ced30b0e285117ad5bcdf6cc940329aadc826e21) - **refactor:** use constant packages and remove unused include [(#2355)](https://github.com/stdlib-js/stdlib/pull/2355) _(by Gunj Joshi)_
- [`343da6f`](https://github.com/stdlib-js/stdlib/commit/343da6faa466294331be4befd603fde2faa83503) - **feat:** add C implementation for `math/base/special/cos` _(by Gunj Joshi, Philipp Burckhardt)_
- [`a985cc2`](https://github.com/stdlib-js/stdlib/commit/a985cc224aa74759783c5c4d9577769a36ed818f) - **feat:** add `math/base/special/nanmin` _(by Ridam Garg, RidamGarg, stdlib-bot, Philipp Burckhardt)_
Expand Down
24 changes: 10 additions & 14 deletions base/special/lnf/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

var toWordf = require( '@stdlib/number/float32/base/to-word' );
var fromWordf = require( '@stdlib/number/float32/base/from-word' );
var isnan = require( './../../../../base/assert/is-nan' );
var isnanf = require( './../../../../base/assert/is-nanf' );
var NINF = require( '@stdlib/constants/float32/ninf' );
var FLOAT32_EXPONENT_MASK = require( '@stdlib/constants/float32/exponent-mask' );
var FLOAT32_EXPONENT_BIAS = require( '@stdlib/constants/float32/exponent-bias' );
Expand Down Expand Up @@ -87,7 +87,6 @@ function lnf( x ) {
var ix;
var t2;
var t1;
var dk;
var k;
var R;
var f;
Expand All @@ -100,7 +99,7 @@ function lnf( x ) {
if ( x === 0.0 ) {
return NINF;
}
if ( isnan( x ) || x < 0.0 ) {
if ( isnanf( x ) || x < 0.0 ) {
return NaN;
}
x = float64ToFloat32( x );
Expand All @@ -109,7 +108,7 @@ function lnf( x ) {

// x < 2**-126
if ( ix < 0x00800000 ) {
k = float64ToFloat32( k - 25 );
k -= 25;

// Subnormal number, scale up x
x = float64ToFloat32( x * TWO25 );
Expand All @@ -120,7 +119,7 @@ function lnf( x ) {
}
k = float64ToFloat32( k + float64ToFloat32( ( ix >> 23 ) - FLOAT32_EXPONENT_BIAS ) ); // eslint-disable-line max-len
ix &= FLOAT32_SIGNIFICAND_MASK;
i = float64ToFloat32( ix + ( 0x95f64 << 3 ) ) & 0x800000;
i = ( ix + ( 0x95f64 << 3 ) ) & 0x800000;

// Normalize x or x/2
x = fromWordf( ix | ( i ^ 0x3f800000 ) );
Expand All @@ -133,22 +132,19 @@ function lnf( x ) {
if ( k === 0 ) {
return 0.0;
}
dk = k;
return float64ToFloat32( float64ToFloat32( dk * LN2_HI ) + float64ToFloat32( dk * LN2_LO ) ); // eslint-disable-line max-len
return float64ToFloat32( float64ToFloat32( k * LN2_HI ) + float64ToFloat32( k * LN2_LO ) ); // eslint-disable-line max-len
}
R = float64ToFloat32( float64ToFloat32( f * f ) * float64ToFloat32( 0.5 - float64ToFloat32( ONE_THIRD * f ) ) ); // eslint-disable-line max-len
if ( k === 0 ) {
return float64ToFloat32( f - R );
}
dk = k;
return float64ToFloat32( float64ToFloat32( dk * LN2_HI ) - float64ToFloat32( float64ToFloat32( R - float64ToFloat32( dk * LN2_LO ) ) - f ) ); // eslint-disable-line max-len
return float64ToFloat32( float64ToFloat32( k * LN2_HI ) - float64ToFloat32( float64ToFloat32( R - float64ToFloat32( k * LN2_LO ) ) - f ) ); // eslint-disable-line max-len
}
s = float64ToFloat32( f / float64ToFloat32( 2.0 + f ) );
dk = k;
z = float64ToFloat32( s * s );
i = float64ToFloat32( ix - ( 0x6147a << 3 ) );
i = ix - ( 0x6147a << 3 );
w = float64ToFloat32( z * z );
j = float64ToFloat32( ( 0x6b851 << 3 ) - ix );
j = ( 0x6b851 << 3 ) - ix;
t1 = float64ToFloat32( w * float64ToFloat32( polyvalP( w ) ) );
t2 = float64ToFloat32( z * float64ToFloat32( polyvalQ( w ) ) );
i |= j;
Expand All @@ -158,12 +154,12 @@ function lnf( x ) {
if ( k === 0 ) {
return float64ToFloat32( f - float64ToFloat32( hfsq - float64ToFloat32( s * float64ToFloat32( hfsq + R ) ) ) ); // eslint-disable-line max-len
}
return float64ToFloat32( float64ToFloat32( dk * LN2_HI ) - float64ToFloat32( float64ToFloat32( hfsq - float64ToFloat32( ( s * float64ToFloat32( hfsq + R ) ) + float64ToFloat32( dk * LN2_LO ) ) ) - f ) ); // eslint-disable-line max-len
return float64ToFloat32( float64ToFloat32( k * LN2_HI ) - float64ToFloat32( float64ToFloat32( hfsq - float64ToFloat32( ( s * float64ToFloat32( hfsq + R ) ) + float64ToFloat32( k * LN2_LO ) ) ) - f ) ); // eslint-disable-line max-len
}
if ( k === 0 ) {
return float64ToFloat32( f - float64ToFloat32( s * float64ToFloat32( f - R ) ) ); // eslint-disable-line max-len
}
return float64ToFloat32( float64ToFloat32( dk * LN2_HI ) - float64ToFloat32( float64ToFloat32( float64ToFloat32( s * float64ToFloat32( f - R ) ) - float64ToFloat32( dk * LN2_LO ) ) - f ) ); // eslint-disable-line max-len
return float64ToFloat32( float64ToFloat32( k * LN2_HI ) - float64ToFloat32( float64ToFloat32( float64ToFloat32( s * float64ToFloat32( f - R ) ) - float64ToFloat32( k * LN2_LO ) ) - f ) ); // eslint-disable-line max-len
}


Expand Down
3 changes: 0 additions & 3 deletions base/special/lnf/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"@stdlib/math/base/napi/unary",
"@stdlib/number/float32/base/to-word",
"@stdlib/number/float32/base/from-word",
"@stdlib/math/base/assert/is-nan",
"@stdlib/constants/float32/ninf",
"@stdlib/constants/float32/exponent-bias",
"@stdlib/constants/float32/exponent-mask",
Expand All @@ -60,7 +59,6 @@
"dependencies": [
"@stdlib/number/float32/base/to-word",
"@stdlib/number/float32/base/from-word",
"@stdlib/math/base/assert/is-nan",
"@stdlib/constants/float32/ninf",
"@stdlib/constants/float32/exponent-bias",
"@stdlib/constants/float32/exponent-mask",
Expand All @@ -81,7 +79,6 @@
"dependencies": [
"@stdlib/number/float32/base/to-word",
"@stdlib/number/float32/base/from-word",
"@stdlib/math/base/assert/is-nan",
"@stdlib/constants/float32/ninf",
"@stdlib/constants/float32/exponent-bias",
"@stdlib/constants/float32/exponent-mask",
Expand Down
7 changes: 3 additions & 4 deletions base/special/lnf/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "stdlib/math/base/special/lnf.h"
#include "stdlib/number/float32/base/to_word.h"
#include "stdlib/number/float32/base/from_word.h"
#include "stdlib/math/base/assert/is_nan.h"
#include "stdlib/constants/float32/ninf.h"
#include "stdlib/constants/float32/exponent_bias.h"
#include "stdlib/constants/float32/exponent_mask.h"
Expand Down Expand Up @@ -152,18 +151,18 @@ float stdlib_base_lnf( const float x ) {
if ( k == 0 ) {
return 0.0f;
}
dk = k;
dk = (float)k;
return ( ( dk * LN2_HI ) + ( dk * LN2_LO ) );
}
R = ( ( f * f ) * ( 0.5f - ( ONE_THIRD * f ) ) );
if ( k == 0 ) {
return ( f - R );
}
dk = k;
dk = (float)k;
return ( ( dk * LN2_HI ) - ( ( R - ( dk * LN2_LO ) ) - f ) );
}
s = ( f / ( 2.0f + f ) );
dk = k;
dk = (float)k;
z = ( s * s );
i = ( ix - ( 0x6147a << 3 ) );
w = ( z * z );
Expand Down
2 changes: 1 addition & 1 deletion base/special/lnf/test/fixtures/julia/runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ file = @__FILE__;
dir = dirname( file );

# Subnormal values:
x = range( 1.0e-39, stop = 1.4e-45, length = 500 );
x = range( 1.0e-39, stop = 1.40129846e-45, length = 500 );
out = joinpath( dir, "subnormal.json" );
gen( x, out );

Expand Down
2 changes: 1 addition & 1 deletion base/special/lnf/test/fixtures/julia/subnormal.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions base/special/lnf/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var tape = require( 'tape' );
var isnan = require( './../../../../base/assert/is-nan' );
var isnanf = require( './../../../../base/assert/is-nanf' );
var PINF = require( '@stdlib/constants/float32/pinf' );
var NINF = require( '@stdlib/constants/float32/ninf' );
var EPS = require( '@stdlib/constants/float32/eps' );
Expand Down Expand Up @@ -217,7 +217,7 @@ tape( 'the function evaluates the natural logarithm of `x` (subnormal values)',
t.equal( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e );
} else {
delta = abs( y - e );
tol = 75.0 * EPS * abs( e );
tol = 7.0 * EPS * abs( e );
t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
}
Expand All @@ -236,6 +236,6 @@ tape( 'the function returns `+infinity` if provided `+infinity`', function test(

tape( 'the function returns `NaN` if provided a negative number', function test( t ) {
var v = lnf( -1.0 );
t.equal( isnan( v ), true, 'returns expected value' );
t.equal( isnanf( v ), true, 'returns expected value' );
t.end();
});
6 changes: 3 additions & 3 deletions base/special/lnf/test/test.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var resolve = require( 'path' ).resolve;
var tape = require( 'tape' );
var isnan = require( './../../../../base/assert/is-nan' );
var isnanf = require( './../../../../base/assert/is-nanf' );
var PINF = require( '@stdlib/constants/float32/pinf' );
var NINF = require( '@stdlib/constants/float32/ninf' );
var EPS = require( '@stdlib/constants/float32/eps' );
Expand Down Expand Up @@ -226,7 +226,7 @@ tape( 'the function evaluates the natural logarithm of `x` (subnormal values)',
t.equal( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e );
} else {
delta = abs( y - e );
tol = 75.0 * EPS * abs( e );
tol = 7.0 * EPS * abs( e );
t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' );
}
}
Expand All @@ -245,6 +245,6 @@ tape( 'the function returns `+infinity` if provided `+infinity`', opts, function

tape( 'the function returns `NaN` if provided a negative number', opts, function test( t ) {
var v = lnf( -1.0 );
t.equal( isnan( v ), true, 'returns expected value' );
t.equal( isnanf( v ), true, 'returns expected value' );
t.end();
});

0 comments on commit 298c890

Please sign in to comment.