Skip to content

Commit 2d1058b

Browse files
committed
docs: update function description for clarity
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 20c6e2f commit 2d1058b

File tree

11 files changed

+39
-72
lines changed

11 files changed

+39
-72
lines changed

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/README.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# kernelLog1pf
2222

23-
> Compute `logf(1+f) - f` for `1+f` in `~[sqrtf(2)/2, sqrtf(2)]`.
23+
> Evaluate a correction term for single-precision base-2 and base-10 logarithms when `1 + f` is in `[√2/2, √2]`.
2424
2525
<section class="usage">
2626

@@ -32,13 +32,13 @@ var kernelLog1pf = require( '@stdlib/math/base/special/kernel-log1pf' );
3232

3333
#### kernelLog1pf( f )
3434

35-
Computes `logf(1+f) - f` for `1+f` in `~[sqrtf(2)/2, sqrtf(2)]`.
35+
Evaluates a correction term for single-precision base-2 and base-10 logarithms when `1 + f` is in `[√2/2, √2]`.
3636

3737
```javascript
3838
var v = kernelLog1pf( 1.0 );
3939
// returns ~0.1931
4040

41-
v = kernelLog1pf( 1.4142135 );
41+
v = kernelLog1pf( 1.4142135381698608 );
4242
// returns ~0.4672
4343

4444
v = kernelLog1pf( NaN );
@@ -53,7 +53,7 @@ v = kernelLog1pf( NaN );
5353

5454
## Notes
5555

56-
- This function is a helper function for computing logarithms in base `e`. Argument reduction and adding the final term of the polynomial must be done by the caller for increased accuracy when different bases are used. For reference, see [`@stdlib/math/base/special/log2f`][@stdlib/math/base/special/log2f] and [`@stdlib/math/base/special/log10f`][@stdlib/math/base/special/log10f].
56+
- This function is a helper function for computing logarithms in base `e`. Argument reduction and adding the final term of the polynomial must be done by the caller for increased accuracy when different bases are used.
5757

5858
</section>
5959

@@ -66,16 +66,17 @@ v = kernelLog1pf( NaN );
6666
<!-- eslint no-undef: "error" -->
6767

6868
```javascript
69-
var linspace = require( '@stdlib/array/base/linspace' );
69+
var uniform = require( '@stdlib/random/array/uniform' );
70+
var logEachMap = require( '@stdlib/console/log-each-map' );
7071
var sqrtf = require( '@stdlib/math/base/special/sqrtf' );
7172
var kernelLog1pf = require( '@stdlib/math/base/special/kernel-log1pf' );
7273

73-
var x = linspace( sqrtf( 2.0 ) / 2.0, sqrtf( 2.0 ), 100 );
74+
var opts = {
75+
'dtype': 'float32'
76+
};
77+
var x = uniform( 100, sqrtf( 2.0 ) / 2.0, sqrtf( 2.0 ), opts );
7478

75-
var i;
76-
for ( i = 0; i < x.length; i++ ) {
77-
console.log( 'kernelLog1pf(%d) = %d', x[ i ], kernelLog1pf( x[ i ] ) );
78-
}
79+
logEachMap( 'kernelLog1pf(%0.4f) = %0.4f', x, kernelLog1pf );
7980
```
8081

8182
</section>
@@ -110,7 +111,7 @@ for ( i = 0; i < x.length; i++ ) {
110111

111112
#### stdlib_base_kernel_log1pf( f )
112113

113-
Computes `logf(1+f) - f` for `1+f` in `~[sqrtf(2)/2, sqrtf(2)]`.
114+
Evaluates a correction term for single-precision base-2 and base-10 logarithms when `1 + f` is in `[√2/2, √2]`.
114115

115116
```c
116117
float out = stdlib_base_kernel_log1pf( 1.0f );
@@ -154,7 +155,7 @@ int main( void ) {
154155
int i;
155156
for ( i = 0; i < 10; i++ ) {
156157
out = stdlib_base_kernel_log1pf( x[ i ] );
157-
printf ( "x[ i ]: %f, out: %f\n", x[ i ], out );
158+
printf ( "kernelLog1pf(%f) = %f\n", x[ i ], out );
158159
}
159160
}
160161
```
@@ -179,10 +180,6 @@ int main( void ) {
179180

180181
<section class="links">
181182

182-
[@stdlib/math/base/special/log2f]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/log2f
183-
184-
[@stdlib/math/base/special/log10f]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/log10f
185-
186183
<!-- <related-links> -->
187184

188185
<!-- </related-links> -->

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/docs/repl.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
{{alias}}( f )
3-
Computes `log(1+f) - f` for `1+f` in `~[sqrt(2)/2, sqrt(2)]` as a
4-
single-precision floating-point number.
3+
Evaluates a correction term for single-precision base-2 and base-10
4+
logarithms when `1 + f` is in `[√2/2, √2]`.
55

66
This function provides a common means for computing logarithms in base e.
77
Argument reduction and adding the final term of the polynomial must be done

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/docs/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// TypeScript Version: 4.1
2020

2121
/**
22-
* Computes `log(1+f) - f` for `1+f` in `~[sqrtf(2)/2, sqrtf(2)]` as a single-precision floating-point number.
22+
* Evaluates a correction term for single-precision base-2 and base-10 logarithms when `1 + f` is in `[√2/2, √2]`.
2323
*
2424
* ## Notes
2525
*

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/include/stdlib/math/base/special/kernel_log1pf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern "C" {
2929
#endif
3030

3131
/**
32-
* Computes `log(1+f) - f` for `1+f` in `~[sqrt(2)/2, sqrt(2)]` as a single-precision floating-point number.
32+
* Evaluates a correction term for single-precision base-2 and base-10 logarithms when `1 + f` is in `[√2/2, √2]`.
3333
*/
3434
float stdlib_base_kernel_log1pf( const float f );
3535

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'use strict';
2020

2121
/**
22-
* Compute `log(1+f) - f` for `1+f` in `~[sqrt(2)/2, sqrt(2)]` as a single-precision floating-point number.
22+
* Evaluate a correction term for single-precision base-2 and base-10 logarithms when `1 + f` is in `[√2/2, √2]`.
2323
*
2424
* @module @stdlib/math/base/special/kernel-log1pf
2525
*

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var TWO = f32( 2.0 );
4848
// MAIN //
4949

5050
/**
51-
* Computes `log(1+f) - f` for `1+f` in `~[sqrt(2)/2, sqrt(2)]` as a single-precision floating-point number.
51+
* Evaluates a correction term for single-precision base-2 and base-10 logarithms when `1 + f` is in `[√2/2, √2]`.
5252
*
5353
* ## Method
5454
*

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' );
2626
// MAIN //
2727

2828
/**
29-
* Computes `log(1+f) - f` for `1+f` in `~[sqrt(2)/2, sqrt(2)]` as a single-precision floating-point number.
29+
* Evaluates a correction term for single-precision base-2 and base-10 logarithms when `1 + f` is in `[√2/2, √2]`.
3030
*
3131
* @private
3232
* @param {number} f - input value

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@stdlib/math/base/special/kernel-log1pf",
33
"version": "0.0.0",
4-
"description": "Compute logf(1+f) - f for 1+f in ~[sqrtf(2)/2, sqrtf(2)].",
4+
"description": "Evaluate a correction term for single-precision base-2 and base-10 logarithms when 1+f is in [√2/2, √2].",
55
"license": "Apache-2.0",
66
"author": {
77
"name": "The Stdlib Authors",

lib/node_modules/@stdlib/math/base/special/kernel-log1pf/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static float polyval_q( const float x ) {
7878
/* End auto-generated functions. */
7979

8080
/**
81-
* Computes `log(1+f) - f` for `1+f` in `~[sqrt(2)/2, sqrt(2)]` as a single-precision floating-point number.
81+
* Evaluates a correction term for single-precision base-2 and base-10 logarithms when `1 + f` is in `[√2/2, √2]`.
8282
*
8383
* ## Method
8484
*
Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2025 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -22,9 +22,8 @@
2222

2323
var tape = require( 'tape' );
2424
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
25-
var absf = require( '@stdlib/math/base/special/absf' );
26-
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
27-
var EPS = require( '@stdlib/constants/float32/eps' );
25+
var isAlmostEqualf = require( '@stdlib/number/float32/base/assert/is-almost-equal' );
26+
var f32 = require( '@stdlib/number/float64/base/to-float32' );
2827
var kernelLog1pf = require( './../lib' );
2928

3029

@@ -38,42 +37,28 @@ tape( 'main export is a function', function test( t ) {
3837

3938
tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
4039
var v = kernelLog1pf( NaN );
41-
t.equal( isnanf( v ), true, 'returns expected value' );
40+
t.strictEqual( isnanf( v ), true, 'returns expected value' );
4241
t.end();
4342
});
4443

45-
tape( 'the function correctly computes `logf(1+f) - f` for `1+f` satisfying `sqrtf( 2 ) / 2 < 1+f < sqrtf( 2 )`', function test( t ) {
44+
tape( 'the function accurately evaluates the correction term for `1 + f` in the interval `[√2/2, √2]`', function test( t ) {
4645
var expected;
47-
var delta;
48-
var tol;
4946
var x;
5047
var y;
5148
var i;
5249
var e;
5350

5451
x = [
55-
1.4142135
52+
f32( 1.4142135623730951 )
5653
];
5754
expected = [
58-
0.46716002
55+
f32( 0.46716000147788844 )
5956
];
6057

6158
for ( i = 0; i < x.length; i++ ) {
6259
y = kernelLog1pf( x[ i ] );
63-
e = float64ToFloat32( expected[ i ] );
64-
if ( y === e ) {
65-
t.equal( y, e, 'x: '+x[ i ]+'. E: '+e );
66-
} else {
67-
delta = absf( y - e );
68-
tol = 130.0 * EPS * absf( e );
69-
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' );
70-
}
60+
e = expected[ i ];
61+
t.strictEqual( isAlmostEqualf( y, e, 241 ), true, 'returns expected value within 241 ulp' );
7162
}
7263
t.end();
7364
});
74-
75-
tape( 'the function returns `0` if provided `0`', function test( t ) {
76-
var v = kernelLog1pf( 0.0 );
77-
t.equal( v, 0.0, 'returns expected value' );
78-
t.end();
79-
});

0 commit comments

Comments
 (0)