Skip to content

Commit 443e6f2

Browse files
feat: add addon for computing the standard deviation of strided arrays
1 parent 11f1341 commit 443e6f2

File tree

2 files changed

+45
-130
lines changed

2 files changed

+45
-130
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 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/stats/base/snanstdev.h"
20+
#include "stdlib/napi/argv.h"
21+
#include "stdlib/napi/argv_int64.h"
22+
#include "stdlib/napi/argv_float.h"
23+
#include "stdlib/napi/argv_strided_float32array.h"
24+
#include "stdlib/napi/create_double.h"
25+
#include "stdlib/napi/export.h"
26+
#include <node_api.h>
27+
28+
/**
29+
* Receives JavaScript callback invocation data.
30+
*
31+
* @param env environment under which the function is invoked
32+
* @param info callback data
33+
* @return Node-API value
34+
*/
35+
static napi_value addon( napi_env env, napi_callback_info info ) {
36+
STDLIB_NAPI_ARGV( env, info, argv, argc, 4 );
37+
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
38+
STDLIB_NAPI_ARGV_INT64( env, stride, argv, 3 );
39+
STDLIB_NAPI_ARGV_FLOAT( env, correction, argv, 1 );
40+
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, stride, argv, 2 );
41+
STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_strided_snanstdev( N, correction, X, stride ), v );
42+
return v;
43+
}
44+
45+
STDLIB_NAPI_MODULE_EXPORT_FCN( addon )

lib/node_modules/@stdlib/stats/base/snanstdev/src/addon.cpp

Lines changed: 0 additions & 130 deletions
This file was deleted.

0 commit comments

Comments
 (0)