Skip to content

Commit 1e45096

Browse files
committed
feat: add JS implementation
--- 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent c15b20d commit 1e45096

File tree

4 files changed

+249
-0
lines changed

4 files changed

+249
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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 sind = require( '@stdlib/math/base/special/sind' );
24+
var cosd = require( '@stdlib/math/base/special/cosd' );
25+
26+
27+
// MAIN //
28+
29+
/**
30+
* Simultaneously computes the sine and cosine of a number and assigns results to a provided output array.
31+
*
32+
* @private
33+
* @param {number} x - input value (in degrees)
34+
* @param {Collection} out - output array
35+
* @param {integer} stride - output array stride
36+
* @param {NonNegativeInteger} offset - output array index offset
37+
* @returns {Collection} output array
38+
*
39+
* @example
40+
* var v = sincosd( 0.0, [ 0.0, 0.0 ], 1, 0 );
41+
* // returns [ ~0.0, ~1.0 ]
42+
*
43+
* @example
44+
* var v = sincosd( 90.0, [ 0.0, 0.0 ], 1, 0 );
45+
* // returns [ ~1.0, ~0.0 ]
46+
*
47+
* @example
48+
* var v = sincosd( -30.0, [ 0.0, 0.0 ], 1, 0 );
49+
* // returns [ ~-0.5, ~0.866 ]
50+
*
51+
* @example
52+
* var v = sincosd( NaN, [ 0.0, 0.0 ], 1, 0 );
53+
* // returns [ NaN, NaN ]
54+
*/
55+
function sincosd( x, out, stride, offset ) {
56+
out[ offset ] = sind( x );
57+
out[ offset + stride ] = cosd( x );
58+
return out;
59+
}
60+
61+
62+
// EXPORTS //
63+
64+
module.exports = sincosd;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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 number.
23+
*
24+
* @module @stdlib/math/base/special/sincosd
25+
*
26+
* @example
27+
* var sincosd = require( '@stdlib/math/base/special/sincosd' );
28+
*
29+
* var v = sincosd( 0.0 );
30+
* // returns [ ~0.0, ~1.0 ]
31+
*
32+
* v = sincosd( 90.0 );
33+
* // returns [ ~1.0, ~0.0 ]
34+
*
35+
* v = sincosd( -30.0 );
36+
* // returns [ ~-0.5, ~0.866 ]
37+
*
38+
* v = sincosd( NaN );
39+
* // returns [ NaN, NaN ]
40+
*
41+
* @example
42+
* var sincosd = require( '@stdlib/math/base/special/sincosd' );
43+
*
44+
* var out = new Float64Array( 2 );
45+
*
46+
* var v = sincosd( out, 0.0 );
47+
* // return <Float64Array>[ ~0.0, ~1.0 ]
48+
*
49+
* var bool = ( v === out );
50+
* // returns true
51+
*/
52+
53+
// MODULES //
54+
55+
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
56+
var main = require( './main.js' );
57+
var assign = require( './assign.js' );
58+
59+
60+
// MAIN //
61+
62+
setReadOnly( main, 'assign', assign );
63+
64+
65+
// EXPORTS //
66+
67+
module.exports = main;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 number.
30+
*
31+
* @param {number} x - input value (in degrees)
32+
* @returns {Array<number>} sine and cosine
33+
*
34+
* @example
35+
* var v = sincosd( 0.0 );
36+
* // returns [ ~0.0, ~1.0 ]
37+
*
38+
* @example
39+
* var v = sincosd( 90.0 );
40+
* // returns [ ~1.0, ~0.0 ]
41+
*
42+
* @example
43+
* var v = sincosd( -30.0 );
44+
* // returns [ ~-0.5, ~0.866 ]
45+
*
46+
* @example
47+
* var v = sincosd( NaN );
48+
* // returns [ NaN, NaN ]
49+
*/
50+
function sincosd( x ) {
51+
return assign( x, [ 0.0, 0.0 ], 1, 0 );
52+
}
53+
54+
55+
// EXPORTS //
56+
57+
module.exports = sincosd;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 Float64Array = require( '@stdlib/array/float64' );
24+
var addon = require( './../src/addon.node' );
25+
26+
27+
// MAIN //
28+
29+
/**
30+
* Simultaneously computes the sine and cosine of a number.
31+
*
32+
* @private
33+
* @param {number} x - input value (in degrees)
34+
* @returns {Array<number>} sine and cosine
35+
*
36+
* @example
37+
* var v = sincosd( 0.0 );
38+
* // returns <Float64Array>[ ~0.0, ~1.0 ]
39+
*
40+
* @example
41+
* var v = sincosd( 90.0 );
42+
* // returns <Float64Array>[ ~1.0, ~0.0 ]
43+
*
44+
* @example
45+
* var v = sincosd( -30.0 );
46+
* // returns <Float64Array>[ ~-0.5, ~0.866 ]
47+
*
48+
* @example
49+
* var v = sincosd( NaN );
50+
* // returns <Float64Array>[ NaN, NaN ]
51+
*/
52+
function sincosd( x ) {
53+
var out = new Float64Array( 2 );
54+
addon( x, out );
55+
return out;
56+
}
57+
58+
59+
// EXPORTS //
60+
61+
module.exports = sincosd;

0 commit comments

Comments
 (0)