-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add math/base/special/acschf
#9842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ivishal-g
wants to merge
14
commits into
stdlib-js:develop
Choose a base branch
from
ivishal-g:acschf
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,798
−0
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b61c7b7
bench: refactor to use string interpolation in buffer/from-array-buffer
ivishal-g 400cdf8
Merge branch 'stdlib-js:develop' into develop
ivishal-g b71f0ba
Merge branch 'stdlib-js:develop' into develop
ivishal-g b2d1650
Merge branch 'stdlib-js:develop' into develop
ivishal-g fd99196
Merge branch 'stdlib-js:develop' into develop
ivishal-g a1106fb
Merge branch 'stdlib-js:develop' into develop
ivishal-g 92b0e51
Merge branch 'stdlib-js:develop' into develop
ivishal-g 2b7fbdc
Merge branch 'stdlib-js:develop' into develop
ivishal-g 96038de
docs: improve doctests for complex number instances in math/base/spec…
ivishal-g 6f35229
problem
ivishal-g cc593a4
feat: add math/base/special/acschf
ivishal-g 810cce3
Merge branch 'stdlib-js:develop' into acschf
ivishal-g 6b26d59
fix: update copyright year in acschf test files to 2026
ivishal-g bb31a8f
chore: update according to code review
ivishal-g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
214 changes: 214 additions & 0 deletions
214
lib/node_modules/@stdlib/math/base/special/acschf/README.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,214 @@ | ||
| <!-- | ||
|
|
||
| @license Apache-2.0 | ||
|
|
||
| Copyright (c) 2026 The Stdlib Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
|
|
||
| --> | ||
|
|
||
| # acschf | ||
|
|
||
| > Computes the [hyperbolic arccosecant][inverse-hyperbolic-functions] of a single-precision floating-point number. | ||
|
|
||
| <section class="usage"> | ||
|
|
||
| ## Usage | ||
|
|
||
| ```javascript | ||
| var acschf = require( '@stdlib/math/base/special/acschf' ); | ||
| ``` | ||
|
|
||
| #### acschf( x ) | ||
|
|
||
| Computes the [hyperbolic arccosecant][inverse-hyperbolic-functions] of `x`. | ||
|
|
||
| ```javascript | ||
| var v = acschf( 0.0 ); | ||
| // returns Infinity | ||
|
|
||
| v = acschf( -0.0 ); | ||
| // returns -Infinity | ||
|
|
||
| v = acschf( 1.0 ); | ||
| // returns ~0.881 | ||
|
|
||
| v = acschf( -1.0 ); | ||
| // returns ~-0.881 | ||
|
|
||
| v = acschf( NaN ); | ||
| // returns NaN | ||
|
|
||
| v = acschf( -Infinity ); | ||
| // returns -0.0 | ||
|
|
||
| v = acschf( Infinity ); | ||
| // returns 0.0 | ||
| ``` | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.usage --> | ||
|
|
||
| <section class="examples"> | ||
|
|
||
| ## Examples | ||
|
|
||
| <!-- eslint no-undef: "error" --> | ||
|
|
||
| ```javascript | ||
| var uniform = require( '@stdlib/random/array/uniform' ); | ||
| var logEachMap = require( '@stdlib/console/log-each-map' ); | ||
| var acschf = require( '@stdlib/math/base/special/acschf' ); | ||
|
|
||
| var x = uniform( 100, 1.0, 5.0, { | ||
| 'dtype': 'float32' | ||
| }); | ||
|
|
||
| logEachMap( 'acschf(%0.4f) = %0.4f', x, acschf ); | ||
| ``` | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.examples --> | ||
|
|
||
| <!-- C interface documentation. --> | ||
|
|
||
| * * * | ||
|
|
||
| <section class="c"> | ||
|
|
||
| ## C APIs | ||
|
|
||
| <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> | ||
|
|
||
| <section class="intro"> | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.intro --> | ||
|
|
||
| <!-- C usage documentation. --> | ||
|
|
||
| <section class="usage"> | ||
|
|
||
| ### Usage | ||
|
|
||
| ```c | ||
| #include "stdlib/math/base/special/acschf.h" | ||
| ``` | ||
|
|
||
| #### stdlib_base_acschf( x ) | ||
|
|
||
| > Compute the [hyperbolic arccosecant][inverse-hyperbolic-functions] of a single-precision floating-point number. | ||
|
|
||
| ```c | ||
| float out = stdlib_base_acschf( 1.0 ); | ||
| // returns ~0.881 | ||
| ``` | ||
|
|
||
| The function accepts the following arguments: | ||
|
|
||
| - **x**: `[in] float` input value. | ||
|
|
||
| ```c | ||
| float stdlib_base_acschf( const float x ); | ||
| ``` | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.usage --> | ||
|
|
||
| <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
|
|
||
| <section class="notes"> | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.notes --> | ||
|
|
||
| <!-- C API usage examples. --> | ||
|
|
||
| <section class="examples"> | ||
|
|
||
| ### Examples | ||
|
|
||
| ```c | ||
| #include "stdlib/math/base/special/acschf.h" | ||
| #include <stdio.h> | ||
|
|
||
| int main( void ) { | ||
| const float x[] = { -5.0f, -3.89f, -2.78f, -1.67f, -0.55f, 0.55f, 1.67f, 2.78f, 3.89f, 5.0f }; | ||
|
|
||
| float v; | ||
| int i; | ||
| for ( i = 0; i < 10; i++ ) { | ||
| v = stdlib_base_acschf( x[ i ] ); | ||
| printf( "acsch(%f) = %f\n", x[ i ], v ); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.examples --> | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.c --> | ||
|
|
||
| <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> | ||
|
|
||
| <section class="related"> | ||
|
|
||
| * * * | ||
|
|
||
| ## See Also | ||
|
|
||
| - <span class="package-name">[`@stdlib/math/base/special/acothf`][@stdlib/math/base/special/acothf]</span><span class="delimiter">: </span><span class="description">compute the inverse hyperbolic cotangent of a single-precision floating-point number.</span> | ||
| - <span class="package-name">[`@stdlib/math/base/special/acscf`][@stdlib/math/base/special/acscf]</span><span class="delimiter">: </span><span class="description">compute the arccosecant of a single-precision floating-point number.</span> | ||
| - <span class="package-name">[`@stdlib/math/base/special/asechf`][@stdlib/math/base/special/asechf]</span><span class="delimiter">: </span><span class="description">compute the hyperbolic arcsecant of a single-precision floating-point number.</span> | ||
| - <span class="package-name">[`@stdlib/math/base/special/asinhf`][@stdlib/math/base/special/asinhf]</span><span class="delimiter">: </span><span class="description">compute the hyperbolic arcsine of a single-precision floating-point number.</span> | ||
| - <span class="package-name">[`@stdlib/math/base/special/cscf`][@stdlib/math/base/special/cscf]</span><span class="delimiter">: </span><span class="description">compute the cosecant of a single-precision floating-point number.</span> | ||
| - <span class="package-name">[`@stdlib/math/base/special/cschf`][@stdlib/math/base/special/cschf]</span><span class="delimiter">: </span><span class="description">compute the hyperbolic cosecant of a single-precision floating-point number.</span> | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.related --> | ||
|
|
||
| <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
|
|
||
| <section class="links"> | ||
|
|
||
| [inverse-hyperbolic-functions]: https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions | ||
|
|
||
| <!-- <related-links> --> | ||
|
|
||
| [@stdlib/math/base/special/acothf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/acothf | ||
|
|
||
| [@stdlib/math/base/special/acscf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/acscf | ||
|
|
||
| [@stdlib/math/base/special/asechf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/asechf | ||
|
|
||
| [@stdlib/math/base/special/asinhf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/asinhf | ||
|
|
||
| [@stdlib/math/base/special/cscf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/cscf | ||
|
|
||
| [@stdlib/math/base/special/cschf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/cschf | ||
|
|
||
| <!-- </related-links> --> | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.links --> | ||
50 changes: 50 additions & 0 deletions
50
lib/node_modules/@stdlib/math/base/special/acschf/benchmark/benchmark.js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /** | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2026 The Stdlib Authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| 'use strict'; | ||
|
|
||
| // MODULES // | ||
|
|
||
| var bench = require( '@stdlib/bench' ); | ||
| var f32 = require( '@stdlib/number/float64/base/to-float32' ); | ||
| var pkg = require( './../package.json' ).name; | ||
| var acschf = require( './../lib' ); | ||
|
|
||
|
|
||
| // MAIN // | ||
|
|
||
| bench( pkg, function benchmark( b ) { | ||
| var x; | ||
| var i; | ||
|
|
||
| x = f32( 1.234567 ); | ||
| i = 0; | ||
|
|
||
| b.tic(); | ||
| while ( i < b.iterations ) { | ||
| x = acschf( x ); | ||
| i += 1; | ||
| } | ||
| b.toc(); | ||
|
|
||
| if ( x !== x ) { | ||
| b.fail( 'unexpected NaN' ); | ||
| } | ||
| b.pass( 'benchmark finished' ); | ||
| b.end(); | ||
| }); |
59 changes: 59 additions & 0 deletions
59
lib/node_modules/@stdlib/math/base/special/acschf/benchmark/benchmark.native.js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /** | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2026 The Stdlib Authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| 'use strict'; | ||
|
|
||
| // MODULES // | ||
|
|
||
| var resolve = require( 'path' ).resolve; | ||
| var bench = require( '@stdlib/bench' ); | ||
| var tryRequire = require( '@stdlib/utils/try-require' ); | ||
| var f32 = require( '@stdlib/number/float64/base/to-float32' ); | ||
| var pkg = require( './../package.json' ).name; | ||
|
|
||
|
|
||
| // VARIABLES // | ||
|
|
||
| var acschf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); | ||
| var opts = { | ||
| 'skip': ( acschf instanceof Error ) | ||
| }; | ||
|
|
||
|
|
||
| // MAIN // | ||
|
|
||
| bench( pkg+'::native', opts, function benchmark( b ) { | ||
| var x; | ||
| var i; | ||
|
|
||
| x = f32( 1.234567 ); | ||
| i = 0; | ||
|
|
||
| b.tic(); | ||
| while ( i < b.iterations ) { | ||
| x = acschf( x ); | ||
| i += 1; | ||
| } | ||
| b.toc(); | ||
|
|
||
| if ( x !== x ) { | ||
| b.fail( 'unexpected NaN' ); | ||
| } | ||
| b.pass( 'benchmark finished' ); | ||
| b.end(); | ||
| }); | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.