Skip to content

Commit b67e47b

Browse files
committed
feat: add math/base/special/acschf
--- 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: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - 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 ---
1 parent 65ac870 commit b67e47b

41 files changed

Lines changed: 2788 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2026 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# acschf
22+
23+
> Computes the [hyperbolic arccosecant][inverse-hyperbolic-functions] of a single-precision floating-point number.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var acschf = require( '@stdlib/math/base/special/acschf' );
31+
```
32+
33+
#### acschf( x )
34+
35+
Computes the [hyperbolic arccosecant][inverse-hyperbolic-functions] of `x`.
36+
37+
```javascript
38+
var v = acschf( 0.0 );
39+
// returns Infinity
40+
41+
v = acschf( -0.0 );
42+
// returns -Infinity
43+
44+
v = acschf( 1.0 );
45+
// returns ~0.881
46+
47+
v = acschf( -1.0 );
48+
// returns ~-0.881
49+
50+
v = acschf( NaN );
51+
// returns NaN
52+
53+
v = acschf( -Infinity );
54+
// returns -0.0
55+
56+
v = acschf( Infinity );
57+
// returns 0.0
58+
```
59+
60+
</section>
61+
62+
<!-- /.usage -->
63+
64+
<section class="examples">
65+
66+
## Examples
67+
68+
<!-- eslint no-undef: "error" -->
69+
70+
```javascript
71+
var uniform = require( '@stdlib/random/array/uniform' );
72+
var logEachMap = require( '@stdlib/console/log-each-map' );
73+
var acschf = require( '@stdlib/math/base/special/acschf' );
74+
75+
var x = uniform( 100, 1.0, 5.0, {
76+
'dtype': 'float32'
77+
});
78+
79+
logEachMap( 'acschf(%0.4f) = %0.4f', x, acschf );
80+
```
81+
82+
</section>
83+
84+
<!-- /.examples -->
85+
86+
<!-- C interface documentation. -->
87+
88+
* * *
89+
90+
<section class="c">
91+
92+
## C APIs
93+
94+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
95+
96+
<section class="intro">
97+
98+
</section>
99+
100+
<!-- /.intro -->
101+
102+
<!-- C usage documentation. -->
103+
104+
<section class="usage">
105+
106+
### Usage
107+
108+
```c
109+
#include "stdlib/math/base/special/acschf.h"
110+
```
111+
112+
#### stdlib_base_acschf( x )
113+
114+
> Compute the [hyperbolic arccosecant][inverse-hyperbolic-functions] of a single-precision floating-point number.
115+
116+
```c
117+
float out = stdlib_base_acschf( 1.0 );
118+
// returns ~0.881
119+
```
120+
121+
The function accepts the following arguments:
122+
123+
- **x**: `[in] float` input value.
124+
125+
```c
126+
float stdlib_base_acschf( const float x );
127+
```
128+
129+
</section>
130+
131+
<!-- /.usage -->
132+
133+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
134+
135+
<section class="notes">
136+
137+
</section>
138+
139+
<!-- /.notes -->
140+
141+
<!-- C API usage examples. -->
142+
143+
<section class="examples">
144+
145+
### Examples
146+
147+
```c
148+
#include "stdlib/math/base/special/acschf.h"
149+
#include <stdio.h>
150+
151+
int main( void ) {
152+
const float x[] = { -5.0f, -3.89f, -2.78f, -1.67f, -0.55f, 0.55f, 1.67f, 2.78f, 3.89f, 5.0f };
153+
154+
float v;
155+
int i;
156+
for ( i = 0; i < 10; i++ ) {
157+
v = stdlib_base_acschf( x[ i ] );
158+
printf( "acsch(%f) = %f\n", x[ i ], v );
159+
}
160+
}
161+
```
162+
163+
</section>
164+
165+
<!-- /.examples -->
166+
167+
</section>
168+
169+
<!-- /.c -->
170+
171+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
172+
173+
<section class="related">
174+
175+
* * *
176+
177+
## See Also
178+
179+
- <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>
180+
- <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>
181+
- <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>
182+
- <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>
183+
- <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>
184+
- <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>
185+
186+
</section>
187+
188+
<!-- /.related -->
189+
190+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
191+
192+
<section class="links">
193+
194+
[inverse-hyperbolic-functions]: https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions
195+
196+
<!-- <related-links> -->
197+
198+
[@stdlib/math/base/special/acothf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/acothf
199+
200+
[@stdlib/math/base/special/acscf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/acscf
201+
202+
[@stdlib/math/base/special/asechf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/asechf
203+
204+
[@stdlib/math/base/special/asinhf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/asinhf
205+
206+
[@stdlib/math/base/special/cscf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/cscf
207+
208+
[@stdlib/math/base/special/cschf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/cschf
209+
210+
<!-- </related-links> -->
211+
212+
</section>
213+
214+
<!-- /.links -->
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
25+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
26+
var pkg = require( './../package.json' ).name;
27+
var acschf = require( './../lib' );
28+
29+
30+
// MAIN //
31+
32+
bench( pkg, function benchmark( b ) {
33+
var x;
34+
var y;
35+
var i;
36+
37+
x = uniform( 100, -50.0, 50.0, {
38+
'dtype': 'float32'
39+
});
40+
41+
b.tic();
42+
for ( i = 0; i < b.iterations; i++ ) {
43+
y = acschf( x[ i % x.length ] );
44+
if ( isnanf( y ) ) {
45+
b.fail( 'should not return NaN' );
46+
}
47+
}
48+
b.toc();
49+
50+
if ( isnanf( y ) ) {
51+
b.fail( 'should not return NaN' );
52+
}
53+
b.pass( 'benchmark finished' );
54+
b.end();
55+
});
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2026 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var resolve = require( 'path' ).resolve;
24+
var bench = require( '@stdlib/bench' );
25+
var tryRequire = require( '@stdlib/utils/try-require' );
26+
var uniform = require( '@stdlib/random/array/uniform' );
27+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
28+
var pkg = require( './../package.json' ).name;
29+
30+
31+
// VARIABLES //
32+
33+
var acschf = tryRequire( resolve( __dirname, './../lib/native.js' ) );
34+
var opts = {
35+
'skip': ( acschf instanceof Error )
36+
};
37+
38+
39+
// MAIN //
40+
41+
bench( pkg+'::native', opts, function benchmark( b ) {
42+
var x;
43+
var y;
44+
var i;
45+
46+
// Generate input data once (valid domain: |x| >= 1)
47+
x = uniform( 100, 1.0, 50.0, {
48+
'dtype': 'float32'
49+
});
50+
51+
b.tic();
52+
for ( i = 0; i < b.iterations; i++ ) {
53+
y = acschf( x[ i % x.length ] );
54+
if ( isnanf( y ) ) {
55+
b.fail( 'should not return NaN' );
56+
}
57+
}
58+
b.toc();
59+
60+
if ( isnanf( y ) ) {
61+
b.fail( 'should not return NaN' );
62+
}
63+
b.pass( 'benchmark finished' );
64+
b.end();
65+
});

0 commit comments

Comments
 (0)