Skip to content

Commit cb4f01b

Browse files
committed
style: linting fix in C implementation
--- 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: na - 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 b4aa6ce commit cb4f01b

File tree

1 file changed

+20
-22
lines changed
  • lib/node_modules/@stdlib/math/base/special/exp10f/src

1 file changed

+20
-22
lines changed

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

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,45 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*
18-
*
1918
* ## Notice
2019
*
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.
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.
2222
*
23-
* ```text
2423
* Copyright 1984, 1991, 2000 by Stephen L. Moshier
2524
*
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.
25+
* Some software in this archive may be from the book _Methods and Programs for Mathematical Functions_
26+
* (Prentice-Hall or Simon & Schuster International, 1989) or from the Cephes Mathematical Library,
27+
* a commercial product. In either event, it is copyrighted by the author.
28+
* What you see here may be used freely but it comes with no support or guarantee.
2729
*
2830
* Stephen L. Moshier
2931
30-
* ```
3132
*/
3233

3334
#include "stdlib/math/base/special/exp10f.h"
34-
#include "stdlib/math/base/special/floorf.h"
35-
#include "stdlib/math/base/special/ldexpf.h"
36-
#include "stdlib/math/base/assert/is_nanf.h"
3735
#include "stdlib/constants/float32/max_base10_exponent.h"
3836
#include "stdlib/constants/float32/min_base10_exponent.h"
3937
#include "stdlib/constants/float32/pinf.h"
38+
#include "stdlib/math/base/assert/is_nanf.h"
39+
#include "stdlib/math/base/special/floorf.h"
40+
#include "stdlib/math/base/special/ldexpf.h"
4041
#include <stdint.h>
4142

42-
// Rounded float values (safely representable in 32-bit float):
43-
static const float LOG210F = 3.3219281f; // ≈ log2(10)
44-
static const float LG102AF = 0.30102539f; // head of log10(2)
45-
static const float LG102BF = 4.6050378e-06f; // tail of log10(2)
46-
43+
// Constants:
44+
static const float LOG210F = 3.3219281f;
45+
static const float LG102AF = 0.30102539f;
46+
static const float LG102BF = 4.6050378e-06f;
4747

48-
// BEGIN: polyval_p
48+
// Evaluate polynomial P(x):
4949
static float polyval_p( const float x ) {
5050
return 2394.2374f + (x * (406.7173f + (x * (11.745273f + (x * 0.04099625f)))));
5151
}
52-
// END: polyval_p
5352

54-
// BEGIN: polyval_q
53+
// Evaluate polynomial Q(x):
5554
static float polyval_q( const float x ) {
5655
return 2079.6082f + (x * (1272.0927f + (x * (85.09362f + (x * 1.0f)))));
5756
}
58-
// END: polyval_q
5957

6058
/**
6159
* Returns 10 raised to the x power (single-precision).
@@ -77,27 +75,27 @@ float stdlib_base_exp10f( const float x ) {
7775
int32_t n;
7876

7977
if ( stdlib_base_is_nanf( x ) ) {
80-
return 0.0f / 0.0f; // NaN
78+
return 0.0f / 0.0f;
8179
}
8280
if ( x > STDLIB_CONSTANT_FLOAT32_MAX_BASE10_EXPONENT ) {
8381
return STDLIB_CONSTANT_FLOAT32_PINF;
8482
}
8583

86-
// Compute n = round(x * log2(10))
84+
// Compute n = round(x * log2(10)):
8785
px = stdlib_base_floorf( (LOG210F * x) + 0.5f );
8886
n = (int32_t)px;
8987

90-
// Compute fractional part f = x - n * log10(2)
88+
// Compute f = x - n * log10(2):
9189
xc = x;
9290
xc -= (px * LG102AF);
9391
xc -= (px * LG102BF);
9492

95-
// Rational approximation of 10^f
93+
// Evaluate rational approximation for 10^f:
9694
xx = xc * xc;
9795
px = xc * polyval_p( xx );
9896
xc = px / (polyval_q( xx ) - px);
9997
xc = 1.0f + stdlib_base_ldexpf( xc, 1 );
10098

101-
// Scale by 2^n
99+
// Return result:
102100
return stdlib_base_ldexpf( xc, n );
103101
}

0 commit comments

Comments
 (0)