1
+
2
+ /**
3
+ * @license Apache-2.0
4
+ *
5
+ * Copyright (c) 2024 The Stdlib Authors.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ #include "stdlib/blas/ext/base/sasumpw.h"
21
+ #include "stdlib/napi/export.h"
22
+ #include "stdlib/napi/argv.h"
23
+ #include "stdlib/napi/argv_int64.h"
24
+ #include "stdlib/napi/argv_strided_float64array.h"
25
+ #include <node_api.h>
26
+ #include <assert.h>
27
+
28
+ /**
29
+ * Receives JavaScript callback invocation data.
30
+ *
31
+ * @private
32
+ * @param env environment under which the function is invoked
33
+ * @param info callback data
34
+ * @return Node-API value
35
+ */
36
+ static napi_value addon ( napi_env env , napi_callback_info info ) {
37
+ STDLIB_NAPI_ARGV ( env , info , argv , argc , 3 );
38
+ STDLIB_NAPI_ARGV_INT64 ( env , N , argv , 0 );
39
+ STDLIB_NAPI_ARGV_INT64 ( env , stride , argv , 2 );
40
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY ( env , X , N , stride , argv , 1 );
41
+
42
+ napi_value v ;
43
+ napi_status status = napi_create_double ( env , (double )stdlib_strided_sasumpw ( N , (float * )X , stride ), & v );
44
+ assert ( status == napi_ok );
45
+
46
+ return v ;
47
+ }
48
+
49
+ STDLIB_NAPI_MODULE_EXPORT_FCN ( addon )
0 commit comments