Repository navigation
feat: add math/base/special/binetf - #16636
Open
RonakChakrawati wants to merge 1 commit into
Open
RonakChakrawati wants to merge 1 commit into
RonakChakrawati wants to merge 1 commit into
Conversation
- add single-precision implementation of Binet's formula extended to real numbers
- add C implementation, native addon bindings, and C header
- add tests, numpy-generated fixtures, benchmarks, and examples
- add documentation, TypeScript declarations, and REPL docs
---
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: passed
- 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: missing_dependencies
- 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: passed
- task: lint_license_headers
status: passed
---
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves a part of #649.
Description
This pull request:
adds
math/base/special/binetf, a single-precision implementation of Binet's formula extended to real numbers, including a C implementation, native addon bindings, and a C headeradds tests with numpy-generated fixtures, plus C and JavaScript benchmarks and examples
adds documentation, TypeScript declarations, and REPL help
Related Issues
This pull request has the following related issues:
Reference Packages
This pull request followed these packages:
math/base/special/binetfor the algorithm and package structuremath/base/special/tanhffor single-precision conventionspackage structure, documentation layout, benchmark layout, test shape, and naming
the
f32-wrapped evaluation strategy and float32 assertion helpersbenchmark input generation ahead of the timed loop
the single-precision overflow threshold of the dominant term:
184.373779296875is the smallest single-precision value at whichpowf(phi,absf(x))exceedsFLT_MAX. Beyond it, the dominant term is evaluated in log space asexpf(ln(phi)*absf(x) - ln(sqrt(5))), and for negativextheln(absf(cospif(x)))correction is folded into the exponent so the result remains real-valuedthe extension of Binet's formula to negative non-integer
xviaphi**x = cos(pi*x)*phi**absf(x), which keeps the result real for all inputsthe cancellation domain: near
x = 0and the negative half-integers the two terms of the formula nearly cancel, so no single-precision result is meaningful there. The fixture generator filters such points (|y|*sqrt(5)/(|t1|+|t2|) < 0.05and|x| < 40), and tests assert absolute error insteadULP tolerances were measured against regenerated fixtures rather than carried over from the double-precision package
Questions
No.
Other
Fixtures in
test/fixtures/python/are generated bytest/fixtures/python/runner.pyusing numpy. Inputs are float32 and expected values are computed in float64 before a single rounding, so the reference is not computed at the precision under test. Thesmall_negativefixture contains 499 points because one sample was dropped by the cancellation filter. Relative tolerances are per-domain measured maxima scaled by at least 2x, up to 200 ULP in the log-space tail where the float32 rounding ofln(phi)is amplified by the magnitude ofx. Regenerating the fixtures from the committed runner produces byte-identical output.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was drafted with Claude Code: the C and JavaScript implementations, the float32 test port, and the documentation were derived from
math/base/special/binet. I built and ran the package myself, ran both test suites (5290 assertions each), verified the JavaScript and native addon outputs are bit-identical on a set of gate inputs including the overflow boundary, and confirmed the committed fixtures are byte-reproducible from the committed generator.@stdlib-js/reviewers