Skip to content

Commit 4b85ad9

Browse files
committed
feat: add math/base/special/kernel-tanf
--- 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 ---
1 parent f398dde commit 4b85ad9

File tree

29 files changed

+367
-656
lines changed

29 files changed

+367
-656
lines changed

lib/node_modules/@stdlib/math/base/special/kernel-tanf/README.md

Lines changed: 31 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
@license Apache-2.0
44
5-
Copyright (c) 2022 The Stdlib Authors.
5+
Copyright (c) 2025 The Stdlib Authors.
66
77
Licensed under the Apache License, Version 2.0 (the "License");
88
you may not use this file except in compliance with the License.
@@ -18,80 +18,54 @@ limitations under the License.
1818
1919
-->
2020

21-
# kernelTan
21+
# kernelTanf
2222

23-
> Compute the [tangent][tangent] of a double-precision floating-point number on `[-π/4, π/4]`.
23+
> Compute the [tangent][tangent] of a number on `[-π/4, π/4]` in single-precision floating-point format.
2424
2525
<section class="usage">
2626

2727
## Usage
2828

2929
```javascript
30-
var kernelTan = require( '@stdlib/math/base/special/kernel-tan' );
30+
var kernelTanf = require( '@stdlib/math/base/special/kernel-tanf' );
3131
```
3232

33-
#### kernelTan( x, y, k )
33+
#### kernelTanf( x, iy )
3434

35-
Computes the [tangent][tangent] of a double-precision floating-point number on `[-π/4, π/4]`.
35+
Computes the [tangent][tangent] of a number on `[-π/4, π/4]` in single-precision floating-point format.
3636

3737
```javascript
38-
var out = kernelTan( 3.141592653589793/4.0, 0.0, 1 );
38+
var out = kernelTanf( 3.141592653589793/4.0, 1 );
3939
// returns ~1.0
4040

41-
out = kernelTan( 3.141592653589793/6.0, 0.0, 1 );
41+
out = kernelTanf( 3.141592653589793/6.0, 1 );
4242
// returns ~0.577
4343

44-
out = kernelTan( 0.664, 5.288e-17, 1 );
44+
out = kernelTanf( 0.664, 1 );
4545
// returns ~0.783
4646
```
4747

48-
If `k = 1`, the function returns `tan(x+y)`. To return the negative inverse `-1/tan(x+y)`, set `k = -1`.
48+
If `k = 1`, the function returns `tan(x)`. To return the negative inverse `-1/tan(x)`, set `k = -1`.
4949

5050
```javascript
51-
var out = kernelTan( 3.141592653589793/4.0, 0.0, -1 );
51+
var out = kernelTanf( 3.141592653589793/4.0, -1 );
5252
// returns ~-1.0
5353
```
5454

55-
If either `x` or `y` is `NaN`, the function returns `NaN`.
55+
If provided `NaN` for `x`, the function returns `NaN`.
5656

5757
```javascript
58-
var out = kernelTan( NaN, 0.0, 1 );
58+
var out = kernelTanf( NaN, 1 );
5959
// returns NaN
6060

61-
out = kernelTan( 3.0, NaN, 1 );
62-
// returns NaN
63-
64-
out = kernelTan( NaN, NaN, 1 );
61+
out = kernelTanf( NaN, -1 );
6562
// returns NaN
6663
```
6764

6865
</section>
6966

7067
<!-- /.usage -->
7168

72-
<section class="notes">
73-
74-
## Notes
75-
76-
- For increased accuracy, the number for which the [tangent][tangent] should be evaluated can be supplied as a [double-double number][double-double-arithmetic] (i.e., a non-evaluated sum of two [double-precision floating-point numbers][ieee754] `x` and `y`).
77-
78-
- As components of a [double-double number][double-double-arithmetic], the two [double-precision floating-point numbers][ieee754] `x` and `y` must satisfy
79-
80-
<!-- <equation class="equation" label="eq:double_double_inequality" align="center" raw="|y| \leq \frac{1}{2} \operatorname{ulp}(x)" alt="Inequality for the two components of a double-double number."> -->
81-
82-
<div class="equation" align="center" data-raw-text="|y| \leq \frac{1}{2} \operatorname{ulp}(x)" data-equation="eq:double_double_inequality">
83-
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/kernel-tan/docs/img/equation_double_double_inequality.svg" alt="Inequality for the two components of a double-double number.">
84-
<br>
85-
</div>
86-
87-
<!-- </equation> -->
88-
89-
where `ulp` stands for [units in the last place][ulp].
90-
91-
</section>
92-
93-
<!-- /.notes -->
94-
9569
<section class="examples">
9670

9771
## Examples
@@ -100,22 +74,13 @@ out = kernelTan( NaN, NaN, 1 );
10074

10175
```javascript
10276
var linspace = require( '@stdlib/array/base/linspace' );
103-
var binomial = require( '@stdlib/random/base/binomial' ).factory;
104-
var PI = require( '@stdlib/constants/float64/pi' );
105-
var kernelTan = require( '@stdlib/math/base/special/kernel-tan' );
77+
var PI = require( '@stdlib/constants/float32/pi' );
78+
var logEachMap = require( '@stdlib/console/log-each-map' );
79+
var kernelTanf = require( '@stdlib/math/base/special/kernel-tanf' );
10680

10781
var x = linspace( -PI/4.0, PI/4.0, 100 );
108-
var rbinom = binomial( 1, 0.5 );
109-
110-
var descr;
111-
var i;
112-
var k;
11382

114-
for ( i = 0; i < x.length; i++ ) {
115-
k = rbinom();
116-
descr = ( k === 1 ) ? 'tan(%d) = %d' : '-1/tan(%d) = %d';
117-
console.log( descr, x[ i ], kernelTan( x[ i ], 0.0, k ) );
118-
}
83+
logEachMap( 'kernelTanf(%0.4f, %d) = %0.4f', x, 1, kernelTanf );
11984
```
12085

12186
</section>
@@ -145,29 +110,28 @@ for ( i = 0; i < x.length; i++ ) {
145110
### Usage
146111

147112
```c
148-
#include "stdlib/math/base/special/kernel_tan.h"
113+
#include "stdlib/math/base/special/kernel_tanf.h"
149114
```
150115

151-
#### stdlib_base_kernel_tan( x, y, k)
116+
#### stdlib_base_kernel_tanf( x, iy )
152117

153-
Computes the [tangent][tangent] of a double-precision floating-point number on `[-π/4, π/4]`.
118+
Computes the [tangent][tangent] of a number on `[-π/4, π/4]` in single-precision floating-point format.
154119

155120
```c
156-
double out = stdlib_base_kernel_tan( 3.141592653589793/4.0, 0.0, 1 );
157-
// returns ~1.0
121+
float out = stdlib_base_kernel_tanf( 3.141592653589793/4.0, 1 );
122+
// returns ~1.0f
158123

159-
out = stdlib_base_kernel_tan( 3.141592653589793/6.0, 0.0, 1 );
160-
// returns ~0.577
124+
out = stdlib_base_kernel_tanf( 3.141592653589793/6.0, 1 );
125+
// returns ~0.577f
161126
```
162127

163128
The function accepts the following arguments:
164129

165130
- **x**: `[in] double` input value (in radians, assumed to be bounded by `~pi/4` in magnitude).
166-
- **y**: `[in] double` tail of `x`.
167-
- **k**: `[in] int32_t` indicates whether `tan(x+y)` (if `k = 1`) or `-1/tan(x+y)` (if `k = -1`) is returned.
131+
- **iy**: `[in] int32_t` indicates whether `tan(x)` (if `iy = 1`) or `-1/tan(x)` (if `iy = -1`) is returned.
168132

169133
```c
170-
double stdlib_base_kernel_tan( const double x, const double y, const int32_t k );
134+
float stdlib_base_kernel_tanf( const double x, const int32_t iy );
171135
```
172136
173137
</section>
@@ -178,10 +142,6 @@ double stdlib_base_kernel_tan( const double x, const double y, const int32_t k )
178142
179143
<section class="notes">
180144
181-
### Notes
182-
183-
- For increased accuracy, the number for which the [tangent][tangent] should be evaluated can be supplied as a [double-double number][double-double-arithmetic] (i.e., a non-evaluated sum of two [double-precision floating-point numbers][ieee754] `x` and `y`).
184-
185145
</section>
186146
187147
<!-- /.notes -->
@@ -193,17 +153,17 @@ double stdlib_base_kernel_tan( const double x, const double y, const int32_t k )
193153
### Examples
194154
195155
```c
196-
#include "stdlib/math/base/special/kernel_tan.h"
156+
#include "stdlib/math/base/special/kernel_tanf.h"
197157
#include <stdio.h>
198158
199159
int main( void ) {
200160
const double x[] = { -0.7853981633974483, -0.6108652381980153, -0.4363323129985824, -0.26179938779914946, -0.08726646259971649, 0.08726646259971649, 0.26179938779914935, 0.43633231299858233, 0.6108652381980153, 0.7853981633974483 };
201161
202-
double out;
162+
float out;
203163
int i;
204164
for ( i = 0; i < 10; i++ ) {
205-
out = stdlib_base_kernel_tan( x[ i ], 0.0, 1 );
206-
printf( "tan(%lf) = %lf\n", x[ i ], out );
165+
out = stdlib_base_kernel_tanf( x[ i ], 1 );
166+
printf( "kernelTanf(%lf, %d) = %f\n", x[ i ], 1, out );
207167
}
208168
}
209169
```
@@ -220,14 +180,6 @@ int main( void ) {
220180

221181
<section class="related">
222182

223-
* * *
224-
225-
## See Also
226-
227-
- <span class="package-name">[`@stdlib/math/base/special/kernel-cos`][@stdlib/math/base/special/kernel-cos]</span><span class="delimiter">: </span><span class="description">compute the cosine of a double-precision floating-point number on \[-π/4, π/4].</span>
228-
- <span class="package-name">[`@stdlib/math/base/special/kernel-sin`][@stdlib/math/base/special/kernel-sin]</span><span class="delimiter">: </span><span class="description">compute the sine of a double-precision floating-point number on \[-π/4, π/4].</span>
229-
- <span class="package-name">[`@stdlib/math/base/special/tan`][@stdlib/math/base/special/tan]</span><span class="delimiter">: </span><span class="description">evaluate the tangent of a number.</span>
230-
231183
</section>
232184

233185
<!-- /.related -->
@@ -238,20 +190,8 @@ int main( void ) {
238190

239191
[tangent]: https://en.wikipedia.org/wiki/Tangent
240192

241-
[double-double-arithmetic]: https://en.wikipedia.org/wiki/Quadruple-precision_floating-point_format#Double-double_arithmetic
242-
243-
[ieee754]: https://en.wikipedia.org/wiki/IEEE_floating_point
244-
245-
[ulp]: https://en.wikipedia.org/wiki/Unit_in_the_last_place
246-
247193
<!-- <related-links> -->
248194

249-
[@stdlib/math/base/special/kernel-cos]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/kernel-cos
250-
251-
[@stdlib/math/base/special/kernel-sin]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/kernel-sin
252-
253-
[@stdlib/math/base/special/tan]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/tan
254-
255195
<!-- </related-links> -->
256196

257197
</section>

lib/node_modules/@stdlib/math/base/special/kernel-tanf/benchmark/benchmark.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -22,10 +22,10 @@
2222

2323
var bench = require( '@stdlib/bench' );
2424
var linspace = require( '@stdlib/array/base/linspace' );
25-
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26-
var PI = require( '@stdlib/constants/float64/pi' );
25+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
26+
var PI = require( '@stdlib/constants/float32/pi' );
2727
var pkg = require( './../package.json' ).name;
28-
var kernelTan = require( './../lib' );
28+
var kernelTanf = require( './../lib' );
2929

3030

3131
// MAIN //
@@ -41,13 +41,13 @@ bench( pkg+':k=1', function benchmark( b ) {
4141

4242
b.tic();
4343
for ( i = 0; i < b.iterations; i++ ) {
44-
y = kernelTan( x[ i % len ], 0.0, 1 );
45-
if ( isnan( y ) ) {
44+
y = kernelTanf( x[ i%len ], 1 );
45+
if ( isnanf( y ) ) {
4646
b.fail( 'should not return NaN' );
4747
}
4848
}
4949
b.toc();
50-
if ( isnan( y ) ) {
50+
if ( isnanf( y ) ) {
5151
b.fail( 'should not return NaN' );
5252
}
5353
b.pass( 'benchmark finished' );
@@ -65,13 +65,13 @@ bench( pkg+':k=-1', function benchmark( b ) {
6565

6666
b.tic();
6767
for ( i = 0; i < b.iterations; i++ ) {
68-
y = kernelTan( x[ i % len ], 0.0, -1 );
69-
if ( isnan( y ) ) {
68+
y = kernelTanf( x[ i%len ], -1 );
69+
if ( isnanf( y ) ) {
7070
b.fail( 'should not return NaN' );
7171
}
7272
}
7373
b.toc();
74-
if ( isnan( y ) ) {
74+
if ( isnanf( y ) ) {
7575
b.fail( 'should not return NaN' );
7676
}
7777
b.pass( 'benchmark finished' );

lib/node_modules/@stdlib/math/base/special/kernel-tanf/benchmark/benchmark.native.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2022 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -23,17 +23,17 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var linspace = require( '@stdlib/array/base/linspace' );
26-
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27-
var PI = require( '@stdlib/constants/float64/pi' );
26+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
27+
var PI = require( '@stdlib/constants/float32/pi' );
2828
var tryRequire = require( '@stdlib/utils/try-require' );
2929
var pkg = require( './../package.json' ).name;
3030

3131

3232
// VARIABLES //
3333

34-
var kernelTan = tryRequire( resolve( __dirname, './../lib/native.js' ) );
34+
var kernelTanf = tryRequire( resolve( __dirname, './../lib/native.js' ) );
3535
var opts = {
36-
'skip': ( kernelTan instanceof Error )
36+
'skip': ( kernelTanf instanceof Error )
3737
};
3838

3939

@@ -50,13 +50,13 @@ bench( pkg+'::native:k=1', opts, function benchmark( b ) {
5050

5151
b.tic();
5252
for ( i = 0; i < b.iterations; i++ ) {
53-
y = kernelTan( x[ i % len ], 0.0, 1 );
54-
if ( isnan( y ) ) {
53+
y = kernelTanf( x[ i%len ], 1 );
54+
if ( isnanf( y ) ) {
5555
b.fail( 'should not return NaN' );
5656
}
5757
}
5858
b.toc();
59-
if ( isnan( y ) ) {
59+
if ( isnanf( y ) ) {
6060
b.fail( 'should not return NaN' );
6161
}
6262
b.pass( 'benchmark finished' );
@@ -74,13 +74,13 @@ bench( pkg+'::native:k=-1', opts, function benchmark( b ) {
7474

7575
b.tic();
7676
for ( i = 0; i < b.iterations; i++ ) {
77-
y = kernelTan( x[ i % len ], 0.0, -1 );
78-
if ( isnan( y ) ) {
77+
y = kernelTanf( x[ i%len ], -1 );
78+
if ( isnanf( y ) ) {
7979
b.fail( 'should not return NaN' );
8080
}
8181
}
8282
b.toc();
83-
if ( isnan( y ) ) {
83+
if ( isnanf( y ) ) {
8484
b.fail( 'should not return NaN' );
8585
}
8686
b.pass( 'benchmark finished' );

lib/node_modules/@stdlib/math/base/special/kernel-tanf/benchmark/c/native/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#/
22
# @license Apache-2.0
33
#
4-
# Copyright (c) 2022 The Stdlib Authors.
4+
# Copyright (c) 2025 The Stdlib Authors.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)