Skip to content

Commit 6a657a1

Browse files
committed
feat: add C 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: na - 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: passed - 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 240f0df commit 6a657a1

File tree

4 files changed

+121
-0
lines changed

4 files changed

+121
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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_SINCOSD_H
20+
#define STDLIB_MATH_BASE_SPECIAL_SINCOSD_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 number.
31+
*/
32+
void stdlib_base_sincosd( const double x, double *sine, double *cosine );
33+
34+
#ifdef __cplusplus
35+
}
36+
#endif
37+
38+
#endif // !STDLIB_MATH_BASE_SPECIAL_SINCOSD_H
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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/sincosd.h"
20+
#include "stdlib/napi/argv.h"
21+
#include "stdlib/napi/argv_double.h"
22+
#include "stdlib/napi/argv_float64array.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_DOUBLE( env, x, argv, 0 );
36+
STDLIB_NAPI_ARGV_FLOAT64ARRAY( env, y, ylen, argv, 1 );
37+
stdlib_base_sincosd( x, &y[ 0 ], &y[ 1 ] );
38+
return NULL;
39+
}
40+
41+
STDLIB_NAPI_MODULE_EXPORT_FCN( addon )
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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/sincosd.h"
20+
#include "stdlib/math/base/special/sind.h"
21+
#include "stdlib/math/base/special/cosd.h"
22+
23+
/**
24+
* Simultaneously computes the sine and cosine of a number.
25+
*
26+
* @param x input value (in degrees)
27+
* @param sine destination to store the sine
28+
* @param cosine destination to store the cosine
29+
*
30+
* @example
31+
* double x = 0.0;
32+
*
33+
* double cosine;
34+
* double sine;
35+
* stdlib_base_sincosd( x, &sine, &cosine );
36+
*/
37+
void stdlib_base_sincosd( const double x, double* sine, double* cosine ) {
38+
*sine = stdlib_base_sind( x );
39+
*cosine = stdlib_base_cosd( x );
40+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
julia 1.5
2+
JSON 0.21

0 commit comments

Comments
 (0)