feat: add `math/base/special/asechf`
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: 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: 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: passed
- task: lint_license_headers status: passed ---
Resolves a part of #649
Description
What is the purpose of this pull request?
This pull request:
- adds a C implementation for
@stdlib/math/base/special/asechf.
The package computes the hyperbolic arcsecant of a single-precision floating-point number using the relationship:
asechf(x) = acosh(1/x)
Since acoshf does not yet have a C implementation, this implementation uses the double-precision acosh function with appropriate float conversions.
Related Issues
Does this pull request have any related issues?
This pull request has the following related issues:
- ref #649
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.
No.
Checklist
Please ensure the following tasks are completed before submitting this pull request.
- [x] Read, understood, and followed the contributing guidelines.
AI Assistance
When authoring the changes proposed in this PR, did you use any kind of AI assistance?
- [x] Yes
- [ ] No
If you answered "yes" above, how did you use AI assistance?
- [x] Code generation (e.g., when writing an implementation or fixing a bug)
- [x] Test/benchmark generation
- [ ] Documentation (including examples)
- [ ] Research and understanding
Disclosure
If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".
I used AI to generate the boilerplate code for the benchmark files and to generate the numerical test fixtures (input/output pairs) for test.c. The core implementation logic and mathematical correctness were manually verified against standard definitions.
@stdlib-js/reviewers
Coverage Report
| Package | Statements | Branches | Functions | Lines |
|---|---|---|---|---|
| math/base/special/asechf | $\color{red}157/160$ $\color{green}+0.00%$ |
$\color{green}4/4$ $\color{green}+0.00%$ |
$\color{red}1/2$ $\color{green}+0.00%$ |
$\color{red}157/160$ $\color{green}+0.00%$ |
The above coverage report was generated for the changes in this PR.
Hi @kgryte! I have implemented the C version of asechf (hyperbolic arcsecant for single-precision floats).
Implementation uses the formula: asechf(x) = acosh(1/x)
Since acoshf doesn't exist in stdlib yet, I'm using acosh (double-precision) with proper float conversions:
- C:
(float)stdlib_base_acosh((double)(1.0f / x)) - JS:
float64ToFloat32(acosh(1.0 / float64ToFloat32(x)))
This approach maintains accuracy while avoiding dependency on non-existent acoshf. The implementation can be optimized later when acoshf is added.
All tests passing, It follows stdlib conventions. Ready for review!
Ref: #649
We need acoshf to be implemented before this PR can move forward; otherwise, we are just creating technical debt.
Ref: https://github.com/stdlib-js/stdlib/pull/5812
Understood @kgryte. I agree that waiting for acoshf avoids future refactoring.
I will keep this PR open and monitor the progress of acoshf. Once that lands, I will update this implementation to use stdlib_base_acoshf directly and ping you for review.