@ohos-ports/math-base-special-kernel-tan 0.0.0-stage → 0.2.4-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +192 -0
- package/NOTICE +1 -0
- package/README.md +342 -2
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +7 -0
- package/docs/img/equation_double_double_inequality.svg +37 -0
- package/docs/types/index.d.ts +68 -0
- package/include/stdlib/math/base/special/kernel_tan.h +40 -0
- package/lib/index.js +49 -0
- package/lib/main.js +183 -0
- package/lib/native.js +72 -0
- package/lib/polyval_t_even.js +47 -0
- package/lib/polyval_t_odd.js +47 -0
- package/manifest.json +84 -0
- package/package.json +80 -4
- package/src/addon.c +43 -0
- package/src/main.c +198 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2019 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
|
+
// TypeScript Version: 4.1
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Computes the tangent of a double-precision floating-point number on `[-π/4, π/4]`.
|
|
23
|
+
*
|
|
24
|
+
* ## Notes
|
|
25
|
+
*
|
|
26
|
+
* - For increased accuracy, the number for which the tangent should be evaluated can be supplied as a double-double number (i.e., a non-evaluated sum of two double-precision floating-point numbers `x` and `y`).
|
|
27
|
+
* - The numbers `x` and `y` must satisfy `|y| < 0.5 * ulp( x )`.
|
|
28
|
+
* - If either `x` or `y` is `NaN`, the function returns `NaN`.
|
|
29
|
+
*
|
|
30
|
+
* @param x - input value (in radians, assumed to be bounded by ~π/4 in magnitude)
|
|
31
|
+
* @param y - tail of `x`
|
|
32
|
+
* @param k - indicates whether tan (if k = 1) or -1/tan (if k = -1) is returned
|
|
33
|
+
* @returns tangent
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* var out = kernelTan( 3.141592653589793/4.0, 0.0, 1 );
|
|
37
|
+
* // returns ~1.0
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* var out = kernelTan( 3.141592653589793/4.0, 0.0, -1 );
|
|
41
|
+
* // returns ~-1.0
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* var out = kernelTan( 3.141592653589793/6.0, 0.0, 1 );
|
|
45
|
+
* // returns ~0.577
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* var out = kernelTan( 0.664, 5.288e-17, 1 );
|
|
49
|
+
* // returns ~0.783
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* var out = kernelTan( NaN, 0.0, 1 );
|
|
53
|
+
* // returns NaN
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* var out = kernelTan( 3.0, NaN, 1 );
|
|
57
|
+
* // returns NaN
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* var out = kernelTan( NaN, NaN, 1 );
|
|
61
|
+
* // returns NaN
|
|
62
|
+
*/
|
|
63
|
+
declare function kernelTan( x: number, y: number, k: -1 | 1 ): number;
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
// EXPORTS //
|
|
67
|
+
|
|
68
|
+
export = kernelTan;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2022 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
|
+
#ifndef STDLIB_MATH_BASE_SPECIAL_KERNEL_TAN_H
|
|
20
|
+
#define STDLIB_MATH_BASE_SPECIAL_KERNEL_TAN_H
|
|
21
|
+
|
|
22
|
+
#include <stdint.h>
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
26
|
+
*/
|
|
27
|
+
#ifdef __cplusplus
|
|
28
|
+
extern "C" {
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Computes the tangent of a double-precision floating-point number on [-π/4, π/4].
|
|
33
|
+
*/
|
|
34
|
+
double stdlib_base_kernel_tan( const double x, const double y, const int32_t k );
|
|
35
|
+
|
|
36
|
+
#ifdef __cplusplus
|
|
37
|
+
}
|
|
38
|
+
#endif
|
|
39
|
+
|
|
40
|
+
#endif // !STDLIB_MATH_BASE_SPECIAL_KERNEL_TAN_H
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2018 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
|
+
/**
|
|
22
|
+
* Compute the tangent of a double-precision floating-point number on `[-π/4, π/4]`.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/math-base-special-kernel-tan
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var kernelTan = require( '@stdlib/math-base-special-kernel-tan' );
|
|
28
|
+
*
|
|
29
|
+
* var out = kernelTan( 3.141592653589793/4.0, 0.0, 1 );
|
|
30
|
+
* // returns ~1.0
|
|
31
|
+
*
|
|
32
|
+
* out = kernelTan( 3.141592653589793/4.0, 0.0, -1 );
|
|
33
|
+
* // returns ~-1.0
|
|
34
|
+
*
|
|
35
|
+
* out = kernelTan( 3.141592653589793/6.0, 0.0, 1 );
|
|
36
|
+
* // returns ~0.577
|
|
37
|
+
*
|
|
38
|
+
* out = kernelTan( 0.664, 5.288e-17, 1 );
|
|
39
|
+
* // returns ~0.783
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
// MODULES //
|
|
43
|
+
|
|
44
|
+
var main = require( './main.js' );
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
// EXPORTS //
|
|
48
|
+
|
|
49
|
+
module.exports = main;
|
package/lib/main.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2018 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
|
+
* ## Notice
|
|
20
|
+
*
|
|
21
|
+
* The following copyright, license, and long comment were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/k_tan.c}. The implementation follows the original, but has been modified for JavaScript.
|
|
22
|
+
*
|
|
23
|
+
* ```text
|
|
24
|
+
* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
|
|
25
|
+
*
|
|
26
|
+
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
27
|
+
* Permission to use, copy, modify, and distribute this
|
|
28
|
+
* software is freely granted, provided that this notice
|
|
29
|
+
* is preserved.
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
'use strict';
|
|
34
|
+
|
|
35
|
+
// MODULES //
|
|
36
|
+
|
|
37
|
+
var getHighWord = require( '@ohos-ports/stdlib-number-float64-base-get-high-word' );
|
|
38
|
+
var setLowWord = require( '@ohos-ports/stdlib-number-float64-base-set-low-word' );
|
|
39
|
+
var polyvalOdd = require( './polyval_t_odd.js' );
|
|
40
|
+
var polyvalEven = require( './polyval_t_even.js' );
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
// VARIABLES //
|
|
44
|
+
|
|
45
|
+
var PIO4 = 7.85398163397448278999e-01;
|
|
46
|
+
var PIO4LO = 3.06161699786838301793e-17;
|
|
47
|
+
var T0 = 3.33333333333334091986e-01; // 3FD55555, 55555563
|
|
48
|
+
|
|
49
|
+
// Absolute value mask: 2147483647 => 0x7fffffff => 01111111111111111111111111111111
|
|
50
|
+
var HIGH_WORD_ABS_MASK = 0x7fffffff|0; // asm type annotation
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
// MAIN //
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Computes the tangent on \\( \approx\[-\pi/4, \pi/4] \\) (except on -0), \\( \pi/4 \approx 0.7854 \\).
|
|
57
|
+
*
|
|
58
|
+
* ## Method
|
|
59
|
+
*
|
|
60
|
+
* - Since \\( \tan(-x) = -\tan(x) \\), we need only to consider positive \\( x \\).
|
|
61
|
+
*
|
|
62
|
+
* - Callers must return \\( \tan(-0) = -0 \\) without calling here since our odd polynomial is not evaluated in a way that preserves \\( -0 \\). Callers may do the optimization \\( \tan(x) \approx x \\) for tiny \\( x \\).
|
|
63
|
+
*
|
|
64
|
+
* - \\( \tan(x) \\) is approximated by a odd polynomial of degree 27 on \\( \[0, 0.67434] \\)
|
|
65
|
+
*
|
|
66
|
+
* ```tex
|
|
67
|
+
* \tan(x) \approx x + T_1 x^3 + \ldots + T_{13} x^{27}
|
|
68
|
+
* ```
|
|
69
|
+
* where
|
|
70
|
+
*
|
|
71
|
+
* ```tex
|
|
72
|
+
* \left| \frac{\tan(x)}{x} - \left( 1 + T_1 x^2 + T_2 x^4 + \ldots + T_{13} x^{26} \right) \right| \le 2^{-59.2}
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* - Note: \\( \tan(x+y) = \tan(x) + \tan'(x) \cdot y \approx \tan(x) + ( 1 + x \cdot x ) \cdot y \\). Therefore, for better accuracy in computing \\( \tan(x+y) \\), let
|
|
76
|
+
*
|
|
77
|
+
* ```tex
|
|
78
|
+
* r = x^3 \cdot \left( T_2+x^2 \cdot (T_3+x^2 \cdot (\ldots+x^2 \cdot (T_{12}+x^2 \cdot T_{13}))) \right)
|
|
79
|
+
* ```
|
|
80
|
+
*
|
|
81
|
+
* then
|
|
82
|
+
*
|
|
83
|
+
* ```tex
|
|
84
|
+
* \tan(x+y) = x^3 + \left( T_1 \cdot x^2 + (x \cdot (r+y)+y) \right)
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* - For \\( x \\) in \\( \[0.67434, \pi/4] \\), let \\( y = \pi/4 - x \\), then
|
|
88
|
+
*
|
|
89
|
+
* ```tex
|
|
90
|
+
* \tan(x) = \tan\left(\tfrac{\pi}{4}-y\right) = \frac{1-\tan(y)}{1+\tan(y)} \\
|
|
91
|
+
* = 1 - 2 \cdot \left( \tan(y) - \tfrac{\tan(y)^2}{1+\tan(y)} \right)
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @param {number} x - input value (in radians, assumed to be bounded by ~π/4 in magnitude)
|
|
95
|
+
* @param {number} y - tail of `x`
|
|
96
|
+
* @param {integer} k - indicates whether tan (if k = 1) or -1/tan (if k = -1) is returned
|
|
97
|
+
* @returns {number} tangent
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* var out = kernelTan( 3.141592653589793/4.0, 0.0, 1 );
|
|
101
|
+
* // returns ~1.0
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* var out = kernelTan( 3.141592653589793/4.0, 0.0, -1 );
|
|
105
|
+
* // returns ~-1.0
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* var out = kernelTan( 3.141592653589793/6.0, 0.0, 1 );
|
|
109
|
+
* // returns ~0.577
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* var out = kernelTan( 0.664, 5.288e-17, 1 );
|
|
113
|
+
* // returns ~0.783
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* var out = kernelTan( NaN, 0.0, 1 );
|
|
117
|
+
* // returns NaN
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* var out = kernelTan( 3.0, NaN, 1 );
|
|
121
|
+
* // returns NaN
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* var out = kernelTan( NaN, NaN, 1 );
|
|
125
|
+
* // returns NaN
|
|
126
|
+
*/
|
|
127
|
+
function kernelTan( x, y, k ) {
|
|
128
|
+
var hx;
|
|
129
|
+
var ix;
|
|
130
|
+
var a;
|
|
131
|
+
var r;
|
|
132
|
+
var s;
|
|
133
|
+
var t;
|
|
134
|
+
var v;
|
|
135
|
+
var w;
|
|
136
|
+
var z;
|
|
137
|
+
|
|
138
|
+
hx = getHighWord( x );
|
|
139
|
+
|
|
140
|
+
// High word of |x|:
|
|
141
|
+
ix = (hx & HIGH_WORD_ABS_MASK)|0; // asm type annotation
|
|
142
|
+
|
|
143
|
+
// Case: |x| >= 0.6744
|
|
144
|
+
if ( ix >= 0x3FE59428 ) {
|
|
145
|
+
if ( x < 0 ) {
|
|
146
|
+
x = -x;
|
|
147
|
+
y = -y;
|
|
148
|
+
}
|
|
149
|
+
z = PIO4 - x;
|
|
150
|
+
w = PIO4LO - y;
|
|
151
|
+
x = z + w;
|
|
152
|
+
y = 0.0;
|
|
153
|
+
}
|
|
154
|
+
z = x * x;
|
|
155
|
+
w = z * z;
|
|
156
|
+
|
|
157
|
+
// Break x^5*(T[1]+x^2*T[2]+...) into x^5(T[1]+x^4*T[3]+...+x^20*T[11]) + x^5(x^2*(T[2]+x^4*T[4]+...+x^22*T[12]))...
|
|
158
|
+
r = polyvalOdd( w );
|
|
159
|
+
v = z * polyvalEven( w );
|
|
160
|
+
s = z * x;
|
|
161
|
+
r = y + (z * ((s * (r + v)) + y));
|
|
162
|
+
r += T0 * s;
|
|
163
|
+
w = x + r;
|
|
164
|
+
if ( ix >= 0x3FE59428 ) {
|
|
165
|
+
v = k;
|
|
166
|
+
return ( 1.0 - ( (hx >> 30) & 2 ) ) * ( v - (2.0 * (x - ((w * w / (w + v)) - r)) )); // eslint-disable-line max-len
|
|
167
|
+
}
|
|
168
|
+
if ( k === 1 ) {
|
|
169
|
+
return w;
|
|
170
|
+
}
|
|
171
|
+
// Compute -1/(x+r) accurately...
|
|
172
|
+
z = setLowWord( w, 0 );
|
|
173
|
+
v = r - (z - x); // z + v = r + x
|
|
174
|
+
a = -1.0 / w; // a = -1/w
|
|
175
|
+
t = setLowWord( a, 0 );
|
|
176
|
+
s = 1.0 + (t * z);
|
|
177
|
+
return t + (a * (s + (t * v)));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
// EXPORTS //
|
|
182
|
+
|
|
183
|
+
module.exports = kernelTan;
|
package/lib/native.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2022 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 addon = require( './../src/addon.node' );
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// MAIN //
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Computes the tangent on \\( \approx\[-\pi/4, \pi/4] \\) (except on -0), \\( \pi/4 \approx 0.7854 \\).
|
|
30
|
+
*
|
|
31
|
+
* @private
|
|
32
|
+
* @param {number} x - input value (in radians, assumed to be bounded by ~π/4 in magnitude)
|
|
33
|
+
* @param {number} y - tail of `x`
|
|
34
|
+
* @param {integer} k - indicates whether tan (if k = 1) or -1/tan (if k = -1) is returned
|
|
35
|
+
* @returns {number} tangent
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* var out = kernelTan( 3.141592653589793/4.0, 0.0, 1 );
|
|
39
|
+
* // returns ~1.0
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* var out = kernelTan( 3.141592653589793/4.0, 0.0, -1 );
|
|
43
|
+
* // returns ~-1.0
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* var out = kernelTan( 3.141592653589793/6.0, 0.0, 1 );
|
|
47
|
+
* // returns ~0.577
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* var out = kernelTan( 0.664, 5.288e-17, 1 );
|
|
51
|
+
* // returns ~0.783
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* var out = kernelTan( NaN, 0.0, 1 );
|
|
55
|
+
* // returns NaN
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* var out = kernelTan( 3.0, NaN, 1 );
|
|
59
|
+
* // returns NaN
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* var out = kernelTan( NaN, NaN, 1 );
|
|
63
|
+
* // returns NaN
|
|
64
|
+
*/
|
|
65
|
+
function kernelTan( x, y, k ) {
|
|
66
|
+
return addon( x, y, k );
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
// EXPORTS //
|
|
71
|
+
|
|
72
|
+
module.exports = kernelTan;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2022 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
|
+
/* This is a generated file. Do not edit directly. */
|
|
20
|
+
'use strict';
|
|
21
|
+
|
|
22
|
+
// MAIN //
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Evaluates a polynomial.
|
|
26
|
+
*
|
|
27
|
+
* ## Notes
|
|
28
|
+
*
|
|
29
|
+
* - The implementation uses [Horner's rule][horners-method] for efficient computation.
|
|
30
|
+
*
|
|
31
|
+
* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method
|
|
32
|
+
*
|
|
33
|
+
* @private
|
|
34
|
+
* @param {number} x - value at which to evaluate the polynomial
|
|
35
|
+
* @returns {number} evaluated polynomial
|
|
36
|
+
*/
|
|
37
|
+
function evalpoly( x ) {
|
|
38
|
+
if ( x === 0.0 ) {
|
|
39
|
+
return 0.05396825397622605;
|
|
40
|
+
}
|
|
41
|
+
return 0.05396825397622605 + (x * (0.0088632398235993 + (x * (0.0014562094543252903 + (x * (0.0002464631348184699 + (x * (0.00007140724913826082 + (x * 0.00002590730518636337))))))))); // eslint-disable-line max-len
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
// EXPORTS //
|
|
46
|
+
|
|
47
|
+
module.exports = evalpoly;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2022 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
|
+
/* This is a generated file. Do not edit directly. */
|
|
20
|
+
'use strict';
|
|
21
|
+
|
|
22
|
+
// MAIN //
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Evaluates a polynomial.
|
|
26
|
+
*
|
|
27
|
+
* ## Notes
|
|
28
|
+
*
|
|
29
|
+
* - The implementation uses [Horner's rule][horners-method] for efficient computation.
|
|
30
|
+
*
|
|
31
|
+
* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method
|
|
32
|
+
*
|
|
33
|
+
* @private
|
|
34
|
+
* @param {number} x - value at which to evaluate the polynomial
|
|
35
|
+
* @returns {number} evaluated polynomial
|
|
36
|
+
*/
|
|
37
|
+
function evalpoly( x ) {
|
|
38
|
+
if ( x === 0.0 ) {
|
|
39
|
+
return 0.13333333333320124;
|
|
40
|
+
}
|
|
41
|
+
return 0.13333333333320124 + (x * (0.021869488294859542 + (x * (0.0035920791075913124 + (x * (0.0005880412408202641 + (x * (0.00007817944429395571 + (x * -0.000018558637485527546))))))))); // eslint-disable-line max-len
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
// EXPORTS //
|
|
46
|
+
|
|
47
|
+
module.exports = evalpoly;
|
package/manifest.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"options": {
|
|
3
|
+
"task": "build"
|
|
4
|
+
},
|
|
5
|
+
"fields": [
|
|
6
|
+
{
|
|
7
|
+
"field": "src",
|
|
8
|
+
"resolve": true,
|
|
9
|
+
"relative": true
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"field": "include",
|
|
13
|
+
"resolve": true,
|
|
14
|
+
"relative": true
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"field": "libraries",
|
|
18
|
+
"resolve": false,
|
|
19
|
+
"relative": false
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"field": "libpath",
|
|
23
|
+
"resolve": true,
|
|
24
|
+
"relative": false
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"confs": [
|
|
28
|
+
{
|
|
29
|
+
"task": "build",
|
|
30
|
+
"src": [
|
|
31
|
+
"./src/main.c"
|
|
32
|
+
],
|
|
33
|
+
"include": [
|
|
34
|
+
"./include"
|
|
35
|
+
],
|
|
36
|
+
"libraries": [
|
|
37
|
+
"-lm"
|
|
38
|
+
],
|
|
39
|
+
"libpath": [],
|
|
40
|
+
"dependencies": [
|
|
41
|
+
"@stdlib/number-float64-base-get-high-word",
|
|
42
|
+
"@stdlib/number-float64-base-set-low-word",
|
|
43
|
+
"@stdlib/napi-export",
|
|
44
|
+
"@stdlib/napi-argv",
|
|
45
|
+
"@stdlib/napi-argv-double",
|
|
46
|
+
"@stdlib/napi-argv-int32",
|
|
47
|
+
"@stdlib/napi-create-double"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"task": "benchmark",
|
|
52
|
+
"src": [
|
|
53
|
+
"./src/main.c"
|
|
54
|
+
],
|
|
55
|
+
"include": [
|
|
56
|
+
"./include"
|
|
57
|
+
],
|
|
58
|
+
"libraries": [
|
|
59
|
+
"-lm"
|
|
60
|
+
],
|
|
61
|
+
"libpath": [],
|
|
62
|
+
"dependencies": [
|
|
63
|
+
"@stdlib/number-float64-base-get-high-word",
|
|
64
|
+
"@stdlib/number-float64-base-set-low-word"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"task": "examples",
|
|
69
|
+
"src": [
|
|
70
|
+
"./src/main.c"
|
|
71
|
+
],
|
|
72
|
+
"include": [
|
|
73
|
+
"./include"
|
|
74
|
+
],
|
|
75
|
+
"libraries": [],
|
|
76
|
+
"libpath": [],
|
|
77
|
+
"dependencies": [
|
|
78
|
+
"@stdlib/number-float64-base-get-high-word",
|
|
79
|
+
"@stdlib/number-float64-base-set-low-word"
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,82 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-ports/math-base-special-kernel-tan",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.4-beta.1",
|
|
4
|
+
"description": "Compute the tangent of a double-precision floating-point number on [-π/4, π/4].",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "The Stdlib Authors",
|
|
8
|
+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
|
9
|
+
},
|
|
10
|
+
"contributors": [
|
|
11
|
+
{
|
|
12
|
+
"name": "The Stdlib Authors",
|
|
13
|
+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"main": "./lib",
|
|
17
|
+
"gypfile": false,
|
|
18
|
+
"directories": {
|
|
19
|
+
"doc": "./docs",
|
|
20
|
+
"include": "./include",
|
|
21
|
+
"lib": "./lib",
|
|
22
|
+
"scripts": "./scripts",
|
|
23
|
+
"src": "./src",
|
|
24
|
+
"dist": "./dist"
|
|
25
|
+
},
|
|
26
|
+
"types": "./docs/types",
|
|
27
|
+
"scripts": {},
|
|
28
|
+
"homepage": "https://stdlib.io",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git://github.com/ohos-ports/ohos-ports.git",
|
|
32
|
+
"directory": "ports/math-base-special-kernel-tan/0.2.4"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/ohos-ports/ohos-ports/issues"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@ohos-ports/stdlib-napi-argv": "^0.2.3-beta.0",
|
|
39
|
+
"@ohos-ports/stdlib-napi-argv-double": "^0.2.2-beta.0",
|
|
40
|
+
"@ohos-ports/stdlib-napi-argv-int32": "^0.2.3-beta.0",
|
|
41
|
+
"@ohos-ports/stdlib-napi-create-double": "^0.0.3-beta.0",
|
|
42
|
+
"@ohos-ports/stdlib-napi-export": "^0.3.1-beta.0",
|
|
43
|
+
"@ohos-ports/stdlib-number-float64-base-get-high-word": "^0.2.3-beta.0",
|
|
44
|
+
"@ohos-ports/stdlib-number-float64-base-set-low-word": "^0.2.3-beta.0",
|
|
45
|
+
"@ohos-ports/stdlib-utils-library-manifest": "^0.2.4-beta.3"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=0.10.0",
|
|
50
|
+
"npm": ">2.7.0"
|
|
51
|
+
},
|
|
52
|
+
"os": [
|
|
53
|
+
"aix",
|
|
54
|
+
"darwin",
|
|
55
|
+
"freebsd",
|
|
56
|
+
"linux",
|
|
57
|
+
"macos",
|
|
58
|
+
"openbsd",
|
|
59
|
+
"openharmony",
|
|
60
|
+
"sunos",
|
|
61
|
+
"win32",
|
|
62
|
+
"windows"
|
|
63
|
+
],
|
|
64
|
+
"keywords": [
|
|
65
|
+
"stdlib",
|
|
66
|
+
"stdmath",
|
|
67
|
+
"mathematics",
|
|
68
|
+
"math",
|
|
69
|
+
"math.tan",
|
|
70
|
+
"tan",
|
|
71
|
+
"tangent",
|
|
72
|
+
"kernel",
|
|
73
|
+
"trig",
|
|
74
|
+
"trigonometry",
|
|
75
|
+
"radians",
|
|
76
|
+
"angle"
|
|
77
|
+
],
|
|
78
|
+
"funding": {
|
|
79
|
+
"type": "opencollective",
|
|
80
|
+
"url": "https://opencollective.com/stdlib"
|
|
81
|
+
}
|
|
82
|
+
}
|