Skip to content

feat: add math/base/special/exp2f - #3366

Open
aayush0325 wants to merge 29 commits into
stdlib-js:developfrom
aayush0325:exp2f
Open

feat: add math/base/special/exp2f#3366
aayush0325 wants to merge 29 commits into
stdlib-js:developfrom
aayush0325:exp2f

Conversation

@aayush0325

@aayush0325 aayush0325 commented Dec 7, 2024

Copy link
Copy Markdown
Member

Progresses #649

Description

What is the purpose of this pull request?

This pull request:

  • adds math/base/special/exp2f

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

What should i do about benchmark/c/cephes ? that doesn't seem to compile locally and on the CI tests as well.

Other

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

No.

Checklist

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


@stdlib-js/reviewers

@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review. labels Dec 7, 2024
@aayush0325

Copy link
Copy Markdown
Member Author

/stdlib update-copyright-years

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Dec 7, 2024
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Dec 7, 2024
@stdlib-bot

stdlib-bot commented Dec 7, 2024

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/exp2f $\\color{green}330/330$
$\\color{green}+0.00\\%$
$\\color{green}17/17$
$\\color{green}+0.00\\%$
$\\color{green}2/2$
$\\color{green}+0.00\\%$
$\\color{green}330/330$
$\\color{green}+0.00\\%$

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

@Planeshifter Planeshifter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on this PR! Looks great overall, but some changes will be needed for the JavaScript implementation.

In main.js, we need to use the helper function

var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );

in order to ensure that all operations are done in a manner consistent with single-precision arithmetic. Recall that in JavaScript, all numbers are double-precision by default, so to emulate single-precision we must, in addition to using the single-precision variants of math functions, explicitly cast intermediate results and constants to single-precision floats.

@Planeshifter Planeshifter added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Dec 15, 2024
@aayush0325

Copy link
Copy Markdown
Member Author

good morning @Planeshifter! I've wrapped the intermediate results and final answers in float64ToFloat32(). If there's anything else that needs to be changed here please let me know.

@aayush0325

aayush0325 commented Dec 15, 2024

Copy link
Copy Markdown
Member Author

Also, as mentioned in the questions section of the PR, what should i do about benchmark/c/cephes since it doesn't seem to compile locally and it fails on CI as well. Is there something that I'm missing from my side? (see this commit)

@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Dec 16, 2024
@kgryte
kgryte requested a review from gunjjoshi March 14, 2025 09:45
@kgryte kgryte removed the Needs Changes Pull request which needs changes before being merged. label Mar 14, 2025
@Planeshifter Planeshifter added the Potential Duplicate There might be another pull request resolving the same issue. label Mar 15, 2025
@gunjjoshi

Copy link
Copy Markdown
Member

/stdlib update-copyright-years

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Mar 19, 2025
@aayush0325

Copy link
Copy Markdown
Member Author

good morning @gunjjoshi! sorry for the delay, I've linked to all the references for your ease, kindly let me know if i have to make any other changes

@aayush0325
aayush0325 requested a review from gunjjoshi April 3, 2025 01:07
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Apr 3, 2025
@kgryte
kgryte requested a review from anandkaranubc May 31, 2025 23:58
@kgryte kgryte removed the Needs Changes Pull request which needs changes before being merged. label May 31, 2025
@kgryte

kgryte commented Aug 12, 2025

Copy link
Copy Markdown
Member

@anandkaranubc Would you mind taking over this PR?

@anandkaranubc

Copy link
Copy Markdown
Contributor

/stdlib merge

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Aug 26, 2025
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Aug 26, 2025

'use strict';

// TODO: replace with TOMS (Openlibm) algo (updating license header and long comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kgryte Does this comment (originally present in exp2) mean following https://github.com/freebsd/freebsd-src/blob/main/lib/msun/src/s_exp2f.c implementation instead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I believe so. The original implementation looks to be based on Cephes, and, generally, we have preferred to use libm over Cephes given that libm is more actively maintained.

anandkaranubc and others added 2 commits August 10, 2026 00:26
---
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_pkg_readmes
    status: passed
  - task: lint_markdown_docs
    status: na
  - 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: passed
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: passed
  - task: lint_c_examples
    status: passed
  - task: lint_c_benchmarks
    status: passed
  - 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
---
@anandkaranubc

Copy link
Copy Markdown
Contributor

/stdlib help

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Aug 10, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

@anandkaranubc, available slash commands include:

  • /stdlib check-files - Check for required files.
  • /stdlib make-commands - Print make commands for package changed in PR.
  • /stdlib update-copyright-years - Update copyright header years.
  • /stdlib lint-autofix - Auto-fix lint errors.
  • /stdlib merge - Merge changes from develop branch into this PR.
  • /stdlib rebase - Rebase this PR on top of develop branch.
  • /stdlib todo - Create a new todo issue.

@anandkaranubc

Copy link
Copy Markdown
Contributor

/stdlib update-copyright-years

@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Aug 10, 2026
@anandkaranubc anandkaranubc added JavaScript Issue involves or relates to JavaScript. C Issue involves or relates to C. METR Pull request associated with the METR project. labels Aug 10, 2026
@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Aug 10, 2026
@anandkaranubc anandkaranubc added the Needs Changes Pull request which needs changes before being merged. label Aug 10, 2026
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Aug 10, 2026
---
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_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: passed
  - 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: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C Issue involves or relates to C. Feature Issue or pull request for adding a new feature. JavaScript Issue involves or relates to JavaScript. Math Issue or pull request specific to math functionality. METR Pull request associated with the METR project. Needs Changes Pull request which needs changes before being merged. Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants