Skip to content

Commit 699976d

Browse files
committed
fix: main structure as per convention
--- 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 4bdea42 commit 699976d

File tree

3 files changed

+77
-23
lines changed

3 files changed

+77
-23
lines changed

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

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*
18+
*
1819
* ## Notice
1920
*
2021
* The original C code, long comment, copyright, license, and constants are from [Cephes]{@link http://www.netlib.org/cephes}. The implementation follows the original, but has been modified for JavaScript.
@@ -51,12 +52,25 @@ var MAXL10 = 38.230809449325611792;
5152
// MAIN //
5253

5354
/**
54-
* Computes `10^x` for a single-precision floating-point number.
55+
* Returns `10` raised to the `x` power.
5556
*
5657
* ## Method
5758
*
58-
* - Range reduction is accomplished by expressing the argument as \\( 10^x = 2^n 10^f \\), with \\( |f| < 0.5 \\log_{10}(2) \\).
59-
* - A polynomial is used to approximate \\( 10^f \\).
59+
* - Range reduction is accomplished by expressing the argument as \\( 10^x = 2^n 10^f \\), with \\( |f| < 0.5 log_{10}(2) \\). The Pade' form
60+
*
61+
* ```tex
62+
* 10^f \approx 1 + f \cdot P(f)
63+
* ```
64+
*
65+
* is used to approximate \\( 10^f \\).
66+
*
67+
* ## Notes
68+
*
69+
* - Relative error:
70+
*
71+
* | arithmetic | domain | # trials | peak | rms |
72+
* |:----------:|:-----------:|:--------:|:-------:|:-------:|
73+
* | IEEE | -38,+38 | 30000 | 9.8e-8 | 2.8e-8 |
6074
*
6175
* @param {number} x - input value
6276
* @returns {number} function value
@@ -66,6 +80,10 @@ var MAXL10 = 38.230809449325611792;
6680
* // returns 1000.0
6781
*
6882
* @example
83+
* var v = exp10f( -9.0 );
84+
* // returns 9.999999717180685e-10
85+
*
86+
* @example
6987
* var v = exp10f( 0.0 );
7088
* // returns 1.0
7189
*
@@ -90,13 +108,13 @@ function exp10f( x ) {
90108
if ( x < (-1 * MAXL10) ) {
91109
return 0.0;
92110
}
93-
111+
// Express 10^x = 10^g 2^n = 10^g 10^( n log10(2) ) = 10^( g + n log10(2) )
94112
px = floorf( (LOG210*x) + 0.5 );
95113
n = px;
96114
x -= px * LG102A;
97115
x -= px * LG102B;
98116

99-
// Polynomial approximation:
117+
// Polynomial approximation for fractional part: 10^f ≈ 1 + f * P(f)
100118
x = 1.0 + ( x * polyval( x ) );
101119

102120
// Multiply by power of 2:

lib/node_modules/@stdlib/math/base/special/exp10f/lib/polyval.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2022 The Stdlib Authors.
4+
* Copyright (c) 2025 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.

lib/node_modules/@stdlib/math/base/special/exp10f/src/main.c

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,19 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*
18+
*
1819
* ## Notice
1920
*
20-
* The original C code, long comment, copyright, license, and constants are from [Cephes]{@link http://www.netlib.org/cephes}.
21-
* The implementation follows the original, but has been modified according to project conventions.
21+
* The original C code, long comment, copyright, license, and constants are from [Cephes]{@link http://www.netlib.org/cephes}. The implementation follows the original, but has been modified according to project conventions.
22+
*
23+
* ```text
24+
* Copyright 1984, 1991, 2000 by Stephen L. Moshier
25+
*
26+
* Some software in this archive may be from the book _Methods and Programs for Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989) or from the Cephes Mathematical Library, a commercial product. In either event, it is copyrighted by the author. What you see here may be used freely but it comes with no support or guarantee.
27+
*
28+
* Stephen L. Moshier
29+
30+
* ```
2231
*/
2332

2433
#include "stdlib/math/base/special/exp10f.h"
@@ -30,42 +39,70 @@
3039
#include "stdlib/math/base/special/ldexpf.h"
3140
#include <stdint.h>
3241

33-
// Cephes constants:
34-
3542
static float LOG210 = 3.32192809488736234787e0;
3643
static float LG102A = 3.00781250000000000000E-1;
3744
static float LG102B = 2.48745663981195213739E-4;
3845
static float MAXL10 = 38.230809449325611792;
46+
47+
/* Begin auto-generated functions. The following functions are auto-generated. Do not edit directly. */
48+
49+
// BEGIN: polyval
50+
3951
/**
40-
* Evaluates a polynomial using Horner's rule.
41-
* P(x)=a5​+x(a4​+x(a3​+x(a2​+x(a1​+xa0​))))
52+
* Evaluates a polynomial.
53+
*
54+
* ## Notes
55+
*
56+
* - The implementation uses [Horner's rule][horners-method] for efficient computation.
4257
*
43-
* @param x input value
44-
* @return result of polynomial evaluation
58+
* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method
59+
*
60+
* @param x value at which to evaluate the polynomial
61+
* @return evaluated polynomial
4562
*/
4663
static float polyval( const float x ) {
4764
return 2.302585167056758e+0f + x * (2.650948748208892e+0f + x * (2.034649854009453e+0f + x * (1.171292686296281e+0f + x * (5.420251702225484e-1f + x * 2.063216740311022e-1f))));
4865
}
4966

67+
// END: polyval
68+
69+
/* End auto-generated functions. */
5070

5171
/**
52-
* Computes 10^x for a single-precision floating-point number.
72+
* Returns `10` raised to the `x` power.
5373
*
5474
* ## Method
5575
*
56-
* - Performs range reduction: 10^x = 2^n * 10^f, where |f| < 0.5*log10(2)
57-
* - Approximates 10^f using a polynomial expansion from Cephes
76+
* - Range reduction is accomplished by expressing the argument as \\( 10^x = 2^n 10^f \\), with \\( |f| < 0.5 log_{10}(2) \\). The Pade' form
77+
*
78+
* ```tex
79+
* 10^f \approx 1 + f \cdot P(f)
80+
* ```
81+
*
82+
* is used to approximate \\( 10^f \\).
83+
*
84+
* ## Notes
85+
*
86+
* - Relative error:
87+
*
88+
* | arithmetic | domain | # trials | peak | rms |
89+
* |:----------:|:-----------:|:--------:|:-------:|:-------:|
90+
* | IEEE | -38,+38 | 30000 | 9.8e-8 | 2.8e-8 |
5891
*
5992
* @param x input value
60-
* @return single-precision result of 10^x
93+
* @return output value
94+
*
95+
* @example
96+
* float v = stdlib_base_exp10f( 2.0 );
97+
* // returns 100.0
6198
*/
6299
float stdlib_base_exp10f( const float x ) {
63100
float xc;
64101
float px;
65102
int32_t n;
66103

67104
if ( stdlib_base_is_nanf( x ) ) {
68-
return 0.0f / 0.0f;
105+
return 0.0f / 0.0f; // NaN
69106
}
70107
if ( x > MAXL10 ) {
71108
return STDLIB_CONSTANT_FLOAT32_PINF;
@@ -76,18 +113,17 @@ float stdlib_base_exp10f( const float x ) {
76113
if ( x == 0.0f ) {
77114
return 1.0f;
78115
}
79-
80-
// Range reduction:
116+
// Express 10^x = 10^g 2^n = 10^g 10^( n log10(2) ) = 10^( g + n log10(2) )
81117
px = stdlib_base_floorf( (LOG210 * x) + 0.5f );
82118
n = (int32_t)px;
83119
xc = x;
84120
xc -= px * LG102A;
85121
xc -= px * LG102B;
86122

87-
// Polynomial approximation: 10^f ≈ 1 + f * P(f)
123+
// Polynomial approximation for fractional part: 10^f ≈ 1 + f * P(f)
88124
px = xc * polyval( xc );
89125
xc = 1.0f + px;
90126

91-
// Multiply by power of 2: 10^x = 10^f * 2^n
127+
// Multiply by power of 2:
92128
return stdlib_base_ldexpf( xc, n );
93129
}

0 commit comments

Comments
 (0)