@stdlib/math-base-special-sincosf 0.1.0

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.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 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_SINCOSF_H
20
+ #define STDLIB_MATH_BASE_SPECIAL_SINCOSF_H
21
+
22
+ /*
23
+ * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
24
+ */
25
+ #ifdef __cplusplus
26
+ extern "C" {
27
+ #endif
28
+
29
+ /**
30
+ * Simultaneously computes the sine and cosine of a single-precision floating-point number (in radians).
31
+ */
32
+ void stdlib_base_sincosf( const float x, float *sine, float *cosine );
33
+
34
+ #ifdef __cplusplus
35
+ }
36
+ #endif
37
+
38
+ #endif // !STDLIB_MATH_BASE_SPECIAL_SINCOSF_H
package/lib/assign.js ADDED
@@ -0,0 +1,223 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 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 and license were part of the original implementation available as part of FreeBSD [k_sin.c]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/k_sin.c} and [k_cos.c]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/k_cos.c}. The implementation follows the original sine and cosine kernels, but has been modified for JavaScript and combined into a single function.
22
+ *
23
+ * ```text
24
+ * Copyright (C) 1993 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 toWordf = require( '@stdlib/number-float32-base-to-word' );
38
+ var rempio2f = require( '@stdlib/math-base-special-rempio2f' );
39
+ var f32 = require( '@stdlib/number-float64-base-to-float32' );
40
+ var FLOAT32_ABS_MASK = require( '@stdlib/constants-float32-abs-mask' );
41
+ var FLOAT32_EXPONENT_MASK = require( '@stdlib/constants-float32-exponent-mask' );
42
+ var FLOAT64_HALF_PI = require( '@stdlib/constants-float64-half-pi' );
43
+ var kernelSincosf = require( '@stdlib/math-base-special-kernel-sincosf' ).assign;
44
+
45
+
46
+ // VARIABLES //
47
+
48
+ // PI/4 = 0.7853981256484985 => 0 01111110 10010010000111111011010 => 0x3f490fda = 1061752768
49
+ var PIO4_WORD = 0x3f490fda|0; // asm type annotation
50
+
51
+ // 3*PI/4 = 2.356194257736206 => 0 10000000 00101101100101111100011 => 0x4016cbe3 = 1075235811
52
+ var THREE_PIO4_WORD = 0x4016cbe3|0; // asm type annotation
53
+
54
+ // 5*PI/4 = 3.9269907474517822 => 0 10000000 11110110101001111010001 => 0x407b53d1 = 1081824209
55
+ var FIVE_PIO4_WORD = 0x407b53d1|0; // asm type annotation
56
+
57
+ // 7*PI/4 = 5.497786998748779 => 0 10000001 01011111110110111011111 => 0x40afeddf = 1085271519
58
+ var SEVEN_PIO4_WORD = 0x40afeddf|0; // asm type annotation
59
+
60
+ // 9*PI/4 = 7.068583011627197 => 0 10000001 11000100011000111010101 => 0x40e231d5 = 1088565717
61
+ var NINE_PIO4_WORD = 0x40e231d5|0; // asm type annotation
62
+
63
+ // 2^-12 = 0.000244140625 => 0 01110011 00000000000000000000000 => 0x39800000 = 964689920
64
+ var SMALL_WORD = 0x39800000|0; // asm type annotation
65
+
66
+ // Small multiples of PI/2 in double-precision floating-point format:
67
+ var PIO2 = FLOAT64_HALF_PI; // 0x3FF921FB, 0x54442D18
68
+ var PI = 2.0 * FLOAT64_HALF_PI; // 0x400921FB, 0x54442D18
69
+ var THREE_PIO2 = 3.0 * FLOAT64_HALF_PI; // 0x4012D97C, 0x7F3321D2
70
+ var TWO_PI = 4.0 * FLOAT64_HALF_PI; // 0x401921FB, 0x54442D18
71
+
72
+ // Array for storing the remainder element:
73
+ var Y = [ 0.0 ];
74
+
75
+
76
+ // MAIN //
77
+
78
+ /**
79
+ * Simultaneously computes the sine and cosine of a single-precision floating-point number (in radians) and assigns the results to a provided output array.
80
+ *
81
+ * ## Method
82
+ *
83
+ * - Let \\(S\\), \\(C\\), and \\(T\\) denote the \\(\sin\\), \\(\cos\\) and \\(\tan\\), respectively, on \\(\[-\pi/4, +\pi/4\]\\).
84
+ *
85
+ * - Reduce the argument \\(x\\) to \\(y = x-k\pi/2\\) in \\(\[-\pi/4, +\pi/4\]\\), and let \\(n = k \mod 4\\).
86
+ *
87
+ * - We have
88
+ *
89
+ * | n | sin(x) | cos(x) | tan(x) |
90
+ * | - | ------ | ------ | ------ |
91
+ * | 0 | S | C | T |
92
+ * | 1 | C | -S | -1/T |
93
+ * | 2 | -S | -C | T |
94
+ * | 3 | -C | S | -1/T |
95
+ *
96
+ * @private
97
+ * @param {number} x - input value (in radians)
98
+ * @param {Collection} out - output array
99
+ * @param {integer} stride - output array stride
100
+ * @param {NonNegativeInteger} offset - output array index offset
101
+ * @returns {Collection} output array
102
+ *
103
+ * @example
104
+ * var v = sincosf( 0.0, [ 0.0, 0.0 ], 1, 0 );
105
+ * // returns [ ~0.0, ~1.0 ]
106
+ *
107
+ * @example
108
+ * var v = sincosf( 3.141592653589793/2.0, [ 0.0, 0.0 ], 1, 0 );
109
+ * // returns [ ~1.0, ~0.0 ]
110
+ *
111
+ * @example
112
+ * var v = sincosf( -3.141592653589793/6.0, [ 0.0, 0.0 ], 1, 0 );
113
+ * // returns [ ~-0.5, ~0.866 ]
114
+ *
115
+ * @example
116
+ * var v = sincosf( NaN, [ 0.0, 0.0 ], 1, 0 );
117
+ * // returns [ NaN, NaN ]
118
+ */
119
+ function sincosf( x, out, stride, offset ) {
120
+ var tmp;
121
+ var hx;
122
+ var ix;
123
+ var n;
124
+
125
+ hx = toWordf( f32( x ) ) |0; // asm type annotation
126
+ ix = (hx & FLOAT32_ABS_MASK)|0; // asm type annotation
127
+
128
+ // Case: |x| ~<= π/4
129
+ if ( ix <= PIO4_WORD ) {
130
+ // Case: |x| < 2^-12
131
+ if ( ix < SMALL_WORD ) {
132
+ if ( (x|0) === 0 ) {
133
+ out[ offset ] = f32( x );
134
+ out[ offset+stride ] = f32( 1.0 );
135
+ return out;
136
+ }
137
+ }
138
+ return kernelSincosf( x, out, stride, offset );
139
+ }
140
+ // Case: |x| ~<= 5π/4
141
+ if ( ix <= FIVE_PIO4_WORD ) {
142
+ // Case: |x| ~<= 3π/4
143
+ if ( ix <= THREE_PIO4_WORD ) {
144
+ if ( hx > 0 ) {
145
+ kernelSincosf( x - PIO2, out, stride, offset );
146
+ tmp = f32( -out[ offset ] );
147
+ out[ offset ] = out[ offset+stride ];
148
+ out[ offset+stride ] = tmp;
149
+ } else {
150
+ kernelSincosf( x + PIO2, out, stride, offset );
151
+ tmp = f32( -out[ offset+stride ] );
152
+ out[ offset+stride ] = out[ offset ];
153
+ out[ offset ] = tmp;
154
+ }
155
+ } else {
156
+ if ( hx > 0 ) {
157
+ kernelSincosf( x - PI, out, stride, offset );
158
+ } else {
159
+ kernelSincosf( x + PI, out, stride, offset );
160
+ }
161
+ out[ offset ] = f32( -out[ offset ] );
162
+ out[ offset+stride ] = f32( -out[ offset+stride ] );
163
+ }
164
+ return out;
165
+ }
166
+ // Case: |x| ~<= 9π/4
167
+ if ( ix <= NINE_PIO4_WORD ) {
168
+ // Case: |x| ~<= 7π/4
169
+ if ( ix <= SEVEN_PIO4_WORD ) {
170
+ if ( hx > 0 ) {
171
+ kernelSincosf( x - THREE_PIO2, out, stride, offset );
172
+ tmp = f32( -out[ offset+stride ] );
173
+ out[ offset+stride ] = out[ offset ];
174
+ out[ offset ] = tmp;
175
+ } else {
176
+ kernelSincosf( x + THREE_PIO2, out, stride, offset );
177
+ tmp = f32( -out[ offset ] );
178
+ out[ offset ] = out[ offset+stride ];
179
+ out[ offset+stride ] = tmp;
180
+ }
181
+ } else if ( hx > 0 ) {
182
+ kernelSincosf( x - TWO_PI, out, stride, offset );
183
+ } else {
184
+ kernelSincosf( x + TWO_PI, out, stride, offset );
185
+ }
186
+ return out;
187
+ }
188
+ // Case: x is NaN or infinity
189
+ if ( ix >= FLOAT32_EXPONENT_MASK ) {
190
+ out[ offset ] = NaN;
191
+ out[ offset+stride ] = NaN;
192
+ return out;
193
+ }
194
+ // Argument reduction...
195
+ n = rempio2f( f32( x ), Y );
196
+
197
+ // Compute the sine and cosine together:
198
+ kernelSincosf( Y[ 0 ], out, stride, offset );
199
+
200
+ switch ( n & 3 ) {
201
+ case 0:
202
+ return out;
203
+ case 1:
204
+ tmp = out[ offset+stride ];
205
+ out[ offset+stride ] = f32( -out[ offset ] );
206
+ out[ offset ] = tmp;
207
+ return out;
208
+ case 2:
209
+ out[ offset ] = f32( -out[ offset ] );
210
+ out[ offset+stride ] = f32( -out[ offset+stride ] );
211
+ return out;
212
+ default:
213
+ tmp = f32( -out[ offset+stride ] );
214
+ out[ offset+stride ] = out[ offset ];
215
+ out[ offset ] = tmp;
216
+ return out;
217
+ }
218
+ }
219
+
220
+
221
+ // EXPORTS //
222
+
223
+ module.exports = sincosf;
package/lib/index.js ADDED
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 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
+ * Simultaneously compute the sine and cosine of a single-precision floating-point number (in radians).
23
+ *
24
+ * @module @stdlib/math-base-special-sincosf
25
+ *
26
+ * @example
27
+ * var sincosf = require( '@stdlib/math-base-special-sincosf' );
28
+ *
29
+ * var v = sincosf( 0.0 );
30
+ * // returns [ ~0.0, ~1.0 ]
31
+ *
32
+ * v = sincosf( 3.141592653589793/2.0 );
33
+ * // returns [ ~1.0, ~0.0 ]
34
+ *
35
+ * v = sincosf( -3.141592653589793/6.0 );
36
+ * // returns [ ~-0.5, ~0.866 ]
37
+ *
38
+ * v = sincosf( NaN );
39
+ * // returns [ NaN, NaN ]
40
+ *
41
+ * @example
42
+ * var Float32Array = require( '@stdlib/array-float32' );
43
+ * var sincosf = require( '@stdlib/math-base-special-sincosf' );
44
+ *
45
+ * var out = new Float32Array( 2 );
46
+ *
47
+ * var v = sincosf.assign( 0.0, out, 1, 0 );
48
+ * // returns <Float32Array>[ ~0.0, ~1.0 ]
49
+ *
50
+ * var bool = ( v === out );
51
+ * // returns true
52
+ */
53
+
54
+ // MODULES //
55
+
56
+ var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
57
+ var main = require( './main.js' );
58
+ var assign = require( './assign.js' );
59
+
60
+
61
+ // MAIN //
62
+
63
+ setReadOnly( main, 'assign', assign );
64
+
65
+
66
+ // EXPORTS //
67
+
68
+ module.exports = main;
package/lib/main.js ADDED
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 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 assign = require( './assign.js' );
24
+
25
+
26
+ // MAIN //
27
+
28
+ /**
29
+ * Simultaneously computes the sine and cosine of a single-precision floating-point number (in radians).
30
+ *
31
+ * @param {number} x - input value (in radians)
32
+ * @returns {Array<number>} sine and cosine
33
+ *
34
+ * @example
35
+ * var v = sincosf( 0.0 );
36
+ * // returns [ ~0.0, ~1.0 ]
37
+ *
38
+ * @example
39
+ * var v = sincosf( 3.141592653589793/2.0 );
40
+ * // returns [ ~1.0, ~0.0 ]
41
+ *
42
+ * @example
43
+ * var v = sincosf( -3.141592653589793/6.0 );
44
+ * // returns [ ~-0.5, ~0.866 ]
45
+ *
46
+ * @example
47
+ * var v = sincosf( NaN );
48
+ * // returns [ NaN, NaN ]
49
+ */
50
+ function sincosf( x ) {
51
+ return assign( x, [ 0.0, 0.0 ], 1, 0 );
52
+ }
53
+
54
+
55
+ // EXPORTS //
56
+
57
+ module.exports = sincosf;
package/lib/native.js ADDED
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 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 Float32Array = require( '@stdlib/array-float32' );
24
+ var addon = require( './../src/addon.node' );
25
+
26
+
27
+ // MAIN //
28
+
29
+ /**
30
+ * Simultaneously computes the sine and cosine of a single-precision floating-point number (in radians).
31
+ *
32
+ * @private
33
+ * @param {number} x - input value (in radians)
34
+ * @returns {Float32Array} sine and cosine
35
+ *
36
+ * @example
37
+ * var v = sincosf( 0.0 );
38
+ * // returns <Float32Array>[ ~0.0, ~1.0 ]
39
+ *
40
+ * @example
41
+ * var v = sincosf( 3.141592653589793/2.0 );
42
+ * // returns <Float32Array>[ ~1.0, ~0.0 ]
43
+ *
44
+ * @example
45
+ * var v = sincosf( -3.141592653589793/6.0 );
46
+ * // returns <Float32Array>[ ~-0.5, ~0.866 ]
47
+ *
48
+ * @example
49
+ * var v = sincosf( NaN );
50
+ * // returns <Float32Array>[ NaN, NaN ]
51
+ */
52
+ function sincosf( x ) {
53
+ var out = new Float32Array( 2 );
54
+ addon( x, out );
55
+ return out;
56
+ }
57
+
58
+
59
+ // EXPORTS //
60
+
61
+ module.exports = sincosf;
package/manifest.json ADDED
@@ -0,0 +1,90 @@
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
+ "libpath": [],
38
+ "dependencies": [
39
+ "@stdlib/napi-argv",
40
+ "@stdlib/napi-argv-float",
41
+ "@stdlib/napi-argv-float32array",
42
+ "@stdlib/napi-export",
43
+ "@stdlib/math-base-special-kernel-sincosf",
44
+ "@stdlib/math-base-special-rempio2f",
45
+ "@stdlib/number-float32-base-to-word",
46
+ "@stdlib/constants-float64-half-pi",
47
+ "@stdlib/constants-float32-exponent-mask",
48
+ "@stdlib/constants-float32-abs-mask"
49
+ ]
50
+ },
51
+ {
52
+ "task": "benchmark",
53
+ "src": [
54
+ "./src/main.c"
55
+ ],
56
+ "include": [
57
+ "./include"
58
+ ],
59
+ "libraries": [],
60
+ "libpath": [],
61
+ "dependencies": [
62
+ "@stdlib/math-base-special-kernel-sincosf",
63
+ "@stdlib/math-base-special-rempio2f",
64
+ "@stdlib/number-float32-base-to-word",
65
+ "@stdlib/constants-float64-half-pi",
66
+ "@stdlib/constants-float32-exponent-mask",
67
+ "@stdlib/constants-float32-abs-mask"
68
+ ]
69
+ },
70
+ {
71
+ "task": "examples",
72
+ "src": [
73
+ "./src/main.c"
74
+ ],
75
+ "include": [
76
+ "./include"
77
+ ],
78
+ "libraries": [],
79
+ "libpath": [],
80
+ "dependencies": [
81
+ "@stdlib/math-base-special-kernel-sincosf",
82
+ "@stdlib/math-base-special-rempio2f",
83
+ "@stdlib/number-float32-base-to-word",
84
+ "@stdlib/constants-float64-half-pi",
85
+ "@stdlib/constants-float32-exponent-mask",
86
+ "@stdlib/constants-float32-abs-mask"
87
+ ]
88
+ }
89
+ ]
90
+ }
package/package.json ADDED
@@ -0,0 +1,87 @@
1
+ {
2
+ "name": "@stdlib/math-base-special-sincosf",
3
+ "version": "0.1.0",
4
+ "description": "Simultaneously compute the sine and cosine of a single-precision floating-point number (in radians).",
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
+ "src": "./src",
23
+ "dist": "./dist"
24
+ },
25
+ "types": "./docs/types",
26
+ "scripts": {},
27
+ "homepage": "https://stdlib.io",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git://github.com/stdlib-js/math-base-special-sincosf.git"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/stdlib-js/stdlib/issues"
34
+ },
35
+ "dependencies": {
36
+ "@stdlib/constants-float32-abs-mask": "^0.2.2",
37
+ "@stdlib/constants-float32-exponent-mask": "^0.2.2",
38
+ "@stdlib/constants-float64-half-pi": "^0.2.2",
39
+ "@stdlib/math-base-special-kernel-sincosf": "github:stdlib-js/math-base-special-kernel-sincosf#main",
40
+ "@stdlib/math-base-special-rempio2f": "github:stdlib-js/math-base-special-rempio2f#main",
41
+ "@stdlib/napi-argv": "^0.2.2",
42
+ "@stdlib/napi-argv-float": "^0.2.2",
43
+ "@stdlib/napi-argv-float32array": "^0.2.2",
44
+ "@stdlib/napi-export": "^0.3.0",
45
+ "@stdlib/number-float32-base-to-word": "^0.2.2",
46
+ "@stdlib/number-float64-base-to-float32": "^0.2.2",
47
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
48
+ "@stdlib/utils-library-manifest": "^0.2.3"
49
+ },
50
+ "devDependencies": {},
51
+ "engines": {
52
+ "node": ">=0.10.0",
53
+ "npm": ">2.7.0"
54
+ },
55
+ "os": [
56
+ "aix",
57
+ "darwin",
58
+ "freebsd",
59
+ "linux",
60
+ "macos",
61
+ "openbsd",
62
+ "sunos",
63
+ "win32",
64
+ "windows"
65
+ ],
66
+ "keywords": [
67
+ "stdlib",
68
+ "stdmath",
69
+ "mathematics",
70
+ "math",
71
+ "math.sin",
72
+ "math.cos",
73
+ "sin",
74
+ "cos",
75
+ "sincos",
76
+ "sincosf",
77
+ "sine",
78
+ "cosine",
79
+ "trig",
80
+ "trigonometry",
81
+ "radians"
82
+ ],
83
+ "funding": {
84
+ "type": "opencollective",
85
+ "url": "https://opencollective.com/stdlib"
86
+ }
87
+ }
package/src/addon.c ADDED
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2025 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
+ #include "stdlib/math/base/special/sincosf.h"
20
+ #include "stdlib/napi/argv.h"
21
+ #include "stdlib/napi/argv_float.h"
22
+ #include "stdlib/napi/argv_float32array.h"
23
+ #include "stdlib/napi/export.h"
24
+ #include <node_api.h>
25
+
26
+ /**
27
+ * Receives JavaScript callback invocation data.
28
+ *
29
+ * @param env environment under which the function is invoked
30
+ * @param info callback data
31
+ * @return Node-API value
32
+ */
33
+ static napi_value addon( napi_env env, napi_callback_info info ) {
34
+ STDLIB_NAPI_ARGV( env, info, argv, argc, 2 );
35
+ STDLIB_NAPI_ARGV_FLOAT( env, x, argv, 0 );
36
+ STDLIB_NAPI_ARGV_FLOAT32ARRAY( env, y, ylen, argv, 1 );
37
+ stdlib_base_sincosf( x, &y[ 0 ], &y[ 1 ] );
38
+ return NULL;
39
+ }
40
+
41
+ STDLIB_NAPI_MODULE_EXPORT_FCN( addon )