Skip to content

Conversation

Deepak91168
Copy link
Contributor

@Deepak91168 Deepak91168 commented Jun 17, 2025

Resolves #6711

Description

What is the purpose of this pull request?

This pull request:

  • Implements the base-10 exponential function for single-precision floating-point numbers.
  • Adds the exp10f package to the @stdlib/math/base/special namespace.
  • Includes TypeScript definitions, C implementation, tests, benchmarks, examples, and documentation for the function.

Related Issues

Does this pull request have any related issues?

No

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Output of:

➜ make test TESTS_FILTER=".*/@stdlib/math/base/special/exp10f/.*"
exp10f.test.log

➜ make benchmark-c-files FILES="$(pwd)/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c/native/benchmark.c"
exp10f.c_examples.log

➜ make benchmark BENCHMARKS_FILTER=".*/@stdlib/math/base/special/exp10f/.*"
exp10f.benchmark.log

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

---
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: passed
  - 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: na
  - 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
---
---
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: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: missing_dependencies
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - 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
---
---
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: missing_dependencies
  - 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
---
---
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: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - 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
---
---
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: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: missing_dependencies
  - 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
---
---
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: passed
  - 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: na
  - task: lint_c_examples
    status: passed
  - 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
---
---
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
---
---
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
---
---
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: 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: na
  - 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
---
---
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: passed
  - 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: na
  - 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: passed
  - task: lint_license_headers
    status: passed
---
---
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: passed
  - 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: na
  - 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
---
---
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: na
  - 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
---
@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review. labels Jun 17, 2025
---
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: na
  - 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
---
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Jun 17, 2025

Coverage Report

Package Statements Branches Functions Lines
math/base/special/exp10f $\color{red}284/286$
$\color{green}+99.30\%$
$\color{red}15/16$
$\color{green}+93.75\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{red}284/286$
$\color{green}+99.30\%$
math/base/special $\color{green}2319/2319$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}0/0$
$\color{green}+100.00\%$
$\color{green}2319/2319$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this PR.

---
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: na
  - 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
---
@Deepak91168 Deepak91168 changed the title feat: Add implementation for math/base/special/exp10f feat: add implementation for math/base/special/exp10f Jun 17, 2025
@Deepak91168
Copy link
Contributor Author

⚠️ Note for reviewers: The CI failure is caused by an unrelated issue in /math/base/special/factorial/benchmark/c/native (missing #include <stdint.h>). This PR does not touch that file.
Please do let me know any changes :)

Workflow link

make[1]: Entering directory '/home/runner/work/stdlib/stdlib/lib/node_modules/@stdlib/math/base/special/factorial/benchmark/c/native'
benchmark.c: In function ‘benchmark’:
benchmark.c:94:9: error: unknown type name ‘int32_t’
   94 |         int32_t x;
      |         ^~~~~~~
benchmark.c:25:1: note: ‘int32_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’?
   24 | #include <sys/time.h>
  +++ |+#include <stdint.h>
   25 | 
benchmark.c:101:22: error: ‘int32_t’ undeclared (first use in this function)
  101 |                 x = (int32_t)floor( 33.0 * rand_double() );
      |                      ^~~~~~~
benchmark.c:101:22: note: ‘int32_t’ is defined in header ‘<stdint.h>’; did you forget to ‘#include <stdint.h>’?
benchmark.c:101:22: note: each undeclared identifier is reported only once for each function it appears in
benchmark.c:101:30: error: expected ‘;’ before ‘floor’
  101 |                 x = (int32_t)floor( 33.0 * rand_double() );
      |                              ^~~~~
      |                              ;
benchmark.c: At top level:
benchmark.c:82:15: warning: ‘rand_double’ defined but not used [-Wunused-function]
   82 | static double rand_double( void ) {
      |               ^~~~~~~~~~~
make[1]: *** [Makefile:124: benchmark.out] Error 1
make[1]: Leaving directory '/home/runner/work/stdlib/stdlib/lib/node_modules/@stdlib/math/base/special/factorial/benchmark/c/native'
Error when attempting to compile benchmark.
ERROR: An error was encountered during execution.

make: *** [/home/runner/work/stdlib/stdlib/tools/make/lib/benchmark/c.mk:84: benchmark-c-files] Error 1

@anandkaranubc anandkaranubc self-requested a review June 18, 2025 22:56
@anandkaranubc
Copy link
Contributor

@Deepak91168 Did you follow any reference implementation for this? It looks like a direct port of exp10, with all the 64-bit types converted to 32-bit ones in the C implementation.

@anandkaranubc
Copy link
Contributor

For the current implementation, I suggest exploring other libraries such as FreeBSD, Cephes, Julia, and Boost to see if they offer a specific single-precision exp10 implementation.

@Deepak91168
Copy link
Contributor Author

@Deepak91168 Did you follow any reference implementation for this? It looks like a direct port of exp10, with all the 64-bit types converted to 32-bit ones in the C implementation.

Thank you for reviewing! Yes, you're right — this was originally a direct port of the double-precision exp10, and I now understand that this approach doesn’t align with what’s expected. While working on it, I had also looked at the invf implementation, which uses a similar workaround via float math. But I now realize that such techniques aren't appropriate here.

For the current implementation, I suggest exploring other libraries such as FreeBSD, Cephes, Julia, and Boost to see if they offer a specific single-precision exp10 implementation.

I’ve found exp10f implementation provided by Cephes, which follows a proper strategy using argument reduction and polynomial approximation specific to floats:
Cephes Single Precision

Sorry for the earlier oversight — I appreciate your guidance. I’ll now rework the implementation accordingly by refering Cephes closely. Please let me know if this direction sounds good to you, or if there's anything else I should consider.

@anandkaranubc
Copy link
Contributor

@Deepak91168 No worries at all. It's totally fine, and honestly, it's great that you caught this early on. Realising it now saves a lot of effort later, and it's all part of the learning process. Referring to Cephes sounds like a solid plan, especially since it’s tailored for single precision. Let me know if you’d like a second pair of eyes once you’ve made updates. Happy to help!

As a quick sanity check, it might also be helpful to look at another reference implementation and compare it with Cephes. If not, Cephes is definitely a good reference.

---
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: 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
---
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
---
---
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: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - 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
---
---
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
---
---
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: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - 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
---
---
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
---
---
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: passed
  - 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: na
  - 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
---
---
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: 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: na
  - 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
---
---
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: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: passed
  - 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: na
  - 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
---
---
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: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: passed
  - 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
---
@Deepak91168
Copy link
Contributor Author

Hello! @anandkaranubc

I'm submitting the implementation for exp10f, closely following the Cephes implementation of exp10f. Range Reduction followed by Polynomial Approximation.

There are a few things I'd like to highlight and would appreciate your guidance on:

1. Failing Test Case Due to Float Precision

  • During testing, one case failed due to an extremely small delta beyond the default tolerance threshold:
not ok 6 within tolerance. x: -37.944557189941406. Value: 1.1361685909791687e-38. Expected: 1.1361687311090151e-38. Delta: 1.401298464324817e-45. Tolerance: 1.3544186724531831e-45.
  ---
    operator: ok
    expected: true
    actual:   false
    at: Test.test (/home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f/test/test.js:68:5)
  ...

Since the delta is just slightly above the threshold, I’ve temporarily increased the tolerance using:

tol = 2 * EPS * abs( expected[i] );

This allows all tests to pass. Please let me know if this is an acceptable solution or if you'd prefer a stricter alternative.

2. CI Failure: Cephes Download Timeout

  • CI is currently failing while attempting to download the cephes library from www.moshier.net:
curl: (28) Failed to connect to www.moshier.net port 80 after 30002 ms: Timeout was reached
make: *** [...cephes_moshier.mk:175: .../moshier_cephes/double.zip] Error 28

However, everything runs fine locally.

3. Local Benchmark Success

➜ make benchmark-c-files FILES="$(pwd)/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c/benchmark.c"
Running benchmark: /home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c/benchmark.c
make[1]: Entering directory '/home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c'
make[1]: Leaving directory '/home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c'
Resolving package path...
Package path: /home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f
Resolving package manifest...
Successfully resolved package manifest.
Resolving include directories...
Resolving source files...
Resolving libraries...
Resolving library paths...
Compiling benchmark...
make[1]: Entering directory '/home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c'
benchmark.c: In function ‘benchmark’:
benchmark.c:108:21: warning: implicit declaration of function ‘exp10f’; did you mean ‘exp2f’? [-Wimplicit-function-declaration]
  108 |                 y = exp10f( x[ i%100 ] );
      |                     ^~~~~~
      |                     exp2f
make[1]: Leaving directory '/home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c'
Successfully compiled benchmark.
Success!

make[1]: Entering directory '/home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c'
TAP version 13
# c::exp10f
  ---
  iterations: 1000000
  elapsed: 0.006929159
  rate: 144317654.750025809
  ...
ok 1 benchmark finished
# c::exp10f
  ---
  iterations: 1000000
  elapsed: 0.007263899
  rate: 137667115.239439398
  ...
ok 2 benchmark finished
# c::exp10f
  ---
  iterations: 1000000
  elapsed: 0.013909817
  rate: 71891673.237119064
  ...
ok 3 benchmark finished
#
1..3
# total 3
# pass  3
#
# ok
make[1]: Leaving directory '/home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c'
➜ make benchmark-c-files FILES="$(pwd)/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c/cephes/benchmark.c"
Running benchmark: /home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c/cephes/benchmark.c
make[1]: Entering directory '/home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c/cephes'
make[1]: Leaving directory '/home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c/cephes'
Resolving package path...
Package path: /home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f
Resolving package manifest...
Successfully resolved package manifest.
Resolving include directories...
Resolving source files...
Resolving libraries...
Resolving library paths...
Compiling benchmark...
make[1]: Entering directory '/home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c/cephes'
/home/deepak/Desktop/forks/stdlib/deps/build/moshier_cephes/cephes/double/hyperg.c: In function ‘hyperg’:
/home/deepak/Desktop/forks/stdlib/deps/build/moshier_cephes/cephes/double/hyperg.c:99:3: warning: ‘pcanc’ may be used uninitialized [-Wmaybe-uninitialized]
   99 | if( pcanc < 1.0e-15 )
      |   ^
/home/deepak/Desktop/forks/stdlib/deps/build/moshier_cephes/cephes/double/hyperg.c:90:27: note: ‘pcanc’ was declared here
   90 | double asum, psum, acanc, pcanc, temp;
      |                           ^~~~~
/home/deepak/Desktop/forks/stdlib/deps/build/moshier_cephes/cephes/double/jv.c: In function ‘jv’:
/home/deepak/Desktop/forks/stdlib/deps/build/moshier_cephes/cephes/double/jv.c:165:1: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  165 | if( an > 2.0 * y )
      | ^~
/home/deepak/Desktop/forks/stdlib/deps/build/moshier_cephes/cephes/double/jv.c:168:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  168 |         if( (n >= 0.0) && (n < 20.0)
      |         ^~
/home/deepak/Desktop/forks/stdlib/deps/build/moshier_cephes/cephes/double/stdtr.c: In function ‘stdtr’:
/home/deepak/Desktop/forks/stdlib/deps/build/moshier_cephes/cephes/double/stdtr.c:180:1: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  180 | if( t < 0 )
      | ^~
/home/deepak/Desktop/forks/stdlib/deps/build/moshier_cephes/cephes/double/stdtr.c:183:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  183 |         p = 0.5 + 0.5 * p;
      |         ^
make[1]: Leaving directory '/home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c/cephes'
Successfully compiled benchmark.
Success!

make[1]: Entering directory '/home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c/cephes'
TAP version 13
# c::cephes::exp10f
  ---
  iterations: 1000000
  elapsed: 0.016671896
  rate: 59981180.373818412
  ...
ok 1 benchmark finished
# c::cephes::exp10f
  ---
  iterations: 1000000
  elapsed: 0.006736040
  rate: 148455172.901992708
  ...
ok 2 benchmark finished
# c::cephes::exp10f
  ---
  iterations: 1000000
  elapsed: 0.008225918
  rate: 121566981.624253660
  ...
ok 3 benchmark finished
#
1..3
# total 3
# pass  3
#
# ok
make[1]: Leaving directory '/home/deepak/Desktop/forks/stdlib/lib/node_modules/@stdlib/math/base/special/exp10f/benchmark/c/cephes'

Minor warnings (in Cephes sources), but no runtime issues

Kindly review this PR and let me know if any changes are required.
Thanks a lot :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: Add implementation for math/base/special/exp10f
3 participants