@stdlib/stats-base-snanstdevpn 0.2.1 → 0.2.3
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.
- package/NOTICE +1 -1
- package/README.md +11 -11
- package/include/stdlib/stats/base/snanstdevpn.h +0 -3
- package/manifest.json +81 -40
- package/package.json +14 -9
- package/src/addon.c +45 -0
- package/include.gypi +0 -53
- package/src/addon.cpp +0 -130
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -250,11 +250,11 @@ console.log( v );
|
|
|
250
250
|
|
|
251
251
|
## See Also
|
|
252
252
|
|
|
253
|
-
- <span class="package-name">[`@stdlib/stats-
|
|
254
|
-
- <span class="package-name">[`@stdlib/stats-
|
|
253
|
+
- <span class="package-name">[`@stdlib/stats-strided/dnanstdevpn`][@stdlib/stats/strided/dnanstdevpn]</span><span class="delimiter">: </span><span class="description">calculate the standard deviation of a double-precision floating-point strided array ignoring NaN values and using a two-pass algorithm.</span>
|
|
254
|
+
- <span class="package-name">[`@stdlib/stats-strided/nanstdevpn`][@stdlib/stats/strided/nanstdevpn]</span><span class="delimiter">: </span><span class="description">calculate the standard deviation of a strided array ignoring NaN values and using a two-pass algorithm.</span>
|
|
255
255
|
- <span class="package-name">[`@stdlib/stats-base/snanstdev`][@stdlib/stats/base/snanstdev]</span><span class="delimiter">: </span><span class="description">calculate the standard deviation of a single-precision floating-point strided array ignoring NaN values.</span>
|
|
256
256
|
- <span class="package-name">[`@stdlib/stats-base/snanvariancepn`][@stdlib/stats/base/snanvariancepn]</span><span class="delimiter">: </span><span class="description">calculate the variance of a single-precision floating-point strided array ignoring NaN values and using a two-pass algorithm.</span>
|
|
257
|
-
- <span class="package-name">[`@stdlib/stats-
|
|
257
|
+
- <span class="package-name">[`@stdlib/stats-strided/sstdevpn`][@stdlib/stats/strided/sstdevpn]</span><span class="delimiter">: </span><span class="description">calculate the standard deviation of a single-precision floating-point strided array using a two-pass algorithm.</span>
|
|
258
258
|
|
|
259
259
|
</section>
|
|
260
260
|
|
|
@@ -286,7 +286,7 @@ See [LICENSE][stdlib-license].
|
|
|
286
286
|
|
|
287
287
|
## Copyright
|
|
288
288
|
|
|
289
|
-
Copyright © 2016-
|
|
289
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
290
290
|
|
|
291
291
|
</section>
|
|
292
292
|
|
|
@@ -299,8 +299,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
299
299
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-snanstdevpn.svg
|
|
300
300
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-base-snanstdevpn
|
|
301
301
|
|
|
302
|
-
[test-image]: https://github.com/stdlib-js/stats-base-snanstdevpn/actions/workflows/test.yml/badge.svg?branch=v0.2.
|
|
303
|
-
[test-url]: https://github.com/stdlib-js/stats-base-snanstdevpn/actions/workflows/test.yml?query=branch:v0.2.
|
|
302
|
+
[test-image]: https://github.com/stdlib-js/stats-base-snanstdevpn/actions/workflows/test.yml/badge.svg?branch=v0.2.3
|
|
303
|
+
[test-url]: https://github.com/stdlib-js/stats-base-snanstdevpn/actions/workflows/test.yml?query=branch:v0.2.3
|
|
304
304
|
|
|
305
305
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-snanstdevpn/main.svg
|
|
306
306
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-base-snanstdevpn?branch=main
|
|
@@ -312,8 +312,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
312
312
|
|
|
313
313
|
-->
|
|
314
314
|
|
|
315
|
-
[chat-image]: https://img.shields.io/
|
|
316
|
-
[chat-url]: https://
|
|
315
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
316
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
317
317
|
|
|
318
318
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
319
319
|
|
|
@@ -344,15 +344,15 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
344
344
|
|
|
345
345
|
<!-- <related-links> -->
|
|
346
346
|
|
|
347
|
-
[@stdlib/stats/
|
|
347
|
+
[@stdlib/stats/strided/dnanstdevpn]: https://www.npmjs.com/package/@stdlib/stats-strided-dnanstdevpn
|
|
348
348
|
|
|
349
|
-
[@stdlib/stats/
|
|
349
|
+
[@stdlib/stats/strided/nanstdevpn]: https://www.npmjs.com/package/@stdlib/stats-strided-nanstdevpn
|
|
350
350
|
|
|
351
351
|
[@stdlib/stats/base/snanstdev]: https://www.npmjs.com/package/@stdlib/stats-base-snanstdev
|
|
352
352
|
|
|
353
353
|
[@stdlib/stats/base/snanvariancepn]: https://www.npmjs.com/package/@stdlib/stats-base-snanvariancepn
|
|
354
354
|
|
|
355
|
-
[@stdlib/stats/
|
|
355
|
+
[@stdlib/stats/strided/sstdevpn]: https://www.npmjs.com/package/@stdlib/stats-strided-sstdevpn
|
|
356
356
|
|
|
357
357
|
<!-- </related-links> -->
|
|
358
358
|
|
package/manifest.json
CHANGED
|
@@ -1,42 +1,83 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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/snanstdevpn.c"
|
|
32
|
+
],
|
|
33
|
+
"include": [
|
|
34
|
+
"./include"
|
|
35
|
+
],
|
|
36
|
+
"libraries": [
|
|
37
|
+
"-lm"
|
|
38
|
+
],
|
|
39
|
+
"libpath": [],
|
|
40
|
+
"dependencies": [
|
|
41
|
+
"@stdlib/napi-export",
|
|
42
|
+
"@stdlib/napi-argv",
|
|
43
|
+
"@stdlib/napi-argv-int64",
|
|
44
|
+
"@stdlib/napi-argv-float",
|
|
45
|
+
"@stdlib/napi-argv-strided-float32array",
|
|
46
|
+
"@stdlib/stats-base-snanvariancepn",
|
|
47
|
+
"@stdlib/napi-create-double"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"task": "benchmark",
|
|
52
|
+
"src": [
|
|
53
|
+
"./src/snanstdevpn.c"
|
|
54
|
+
],
|
|
55
|
+
"include": [
|
|
56
|
+
"./include"
|
|
57
|
+
],
|
|
58
|
+
"libraries": [
|
|
59
|
+
"-lm"
|
|
60
|
+
],
|
|
61
|
+
"libpath": [],
|
|
62
|
+
"dependencies": [
|
|
63
|
+
"@stdlib/stats-base-snanvariancepn"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"task": "examples",
|
|
68
|
+
"src": [
|
|
69
|
+
"./src/snanstdevpn.c"
|
|
70
|
+
],
|
|
71
|
+
"include": [
|
|
72
|
+
"./include"
|
|
73
|
+
],
|
|
74
|
+
"libraries": [
|
|
75
|
+
"-lm"
|
|
76
|
+
],
|
|
77
|
+
"libpath": [],
|
|
78
|
+
"dependencies": [
|
|
79
|
+
"@stdlib/stats-base-snanvariancepn"
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
]
|
|
42
83
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/stats-base-snanstdevpn",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Calculate the standard deviation of a single-precision floating-point strided array ignoring NaN values and using a two-pass algorithm.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -34,13 +34,19 @@
|
|
|
34
34
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@stdlib/assert-is-error": "^0.2.
|
|
38
|
-
"@stdlib/math-base-special-sqrt": "^0.2.
|
|
39
|
-
"@stdlib/
|
|
40
|
-
"@stdlib/
|
|
41
|
-
"@stdlib/
|
|
42
|
-
"@stdlib/
|
|
43
|
-
"@stdlib/
|
|
37
|
+
"@stdlib/assert-is-error": "^0.2.3",
|
|
38
|
+
"@stdlib/math-base-special-sqrt": "^0.2.3",
|
|
39
|
+
"@stdlib/napi-argv": "^0.2.3",
|
|
40
|
+
"@stdlib/napi-argv-float": "^0.2.3",
|
|
41
|
+
"@stdlib/napi-argv-int64": "^0.2.3",
|
|
42
|
+
"@stdlib/napi-argv-strided-float32array": "^0.2.3",
|
|
43
|
+
"@stdlib/napi-create-double": "^0.0.3",
|
|
44
|
+
"@stdlib/napi-export": "^0.3.1",
|
|
45
|
+
"@stdlib/number-float64-base-to-float32": "^0.2.2",
|
|
46
|
+
"@stdlib/stats-base-snanvariancepn": "^0.2.2",
|
|
47
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3",
|
|
48
|
+
"@stdlib/utils-library-manifest": "^0.2.4",
|
|
49
|
+
"@stdlib/utils-try-require": "^0.2.3"
|
|
44
50
|
},
|
|
45
51
|
"devDependencies": {},
|
|
46
52
|
"engines": {
|
|
@@ -82,7 +88,6 @@
|
|
|
82
88
|
"double",
|
|
83
89
|
"float32array"
|
|
84
90
|
],
|
|
85
|
-
"__stdlib__": {},
|
|
86
91
|
"funding": {
|
|
87
92
|
"type": "opencollective",
|
|
88
93
|
"url": "https://opencollective.com/stdlib"
|
package/src/addon.c
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
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/stats/base/snanstdevpn.h"
|
|
20
|
+
#include "stdlib/napi/export.h"
|
|
21
|
+
#include "stdlib/napi/argv.h"
|
|
22
|
+
#include "stdlib/napi/argv_int64.h"
|
|
23
|
+
#include "stdlib/napi/argv_float.h"
|
|
24
|
+
#include "stdlib/napi/argv_strided_float32array.h"
|
|
25
|
+
#include "stdlib/napi/create_double.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_FLOAT( env, correction, argv, 1 );
|
|
39
|
+
STDLIB_NAPI_ARGV_INT64( env, stride, argv, 3 );
|
|
40
|
+
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, stride, argv, 2 );
|
|
41
|
+
STDLIB_NAPI_CREATE_DOUBLE( env, (double)stdlib_strided_snanstdevpn( N, correction, X, stride ), v );
|
|
42
|
+
return v;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
STDLIB_NAPI_MODULE_EXPORT_FCN( addon )
|
package/include.gypi
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# @license Apache-2.0
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2020 The Stdlib Authors.
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
# you may not use this file except in compliance with the License.
|
|
7
|
-
# You may obtain a copy of the License at
|
|
8
|
-
#
|
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
#
|
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
# See the License for the specific language governing permissions and
|
|
15
|
-
# limitations under the License.
|
|
16
|
-
|
|
17
|
-
# A GYP include file for building a Node.js native add-on.
|
|
18
|
-
#
|
|
19
|
-
# Main documentation:
|
|
20
|
-
#
|
|
21
|
-
# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md
|
|
22
|
-
# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md
|
|
23
|
-
{
|
|
24
|
-
# Define variables to be used throughout the configuration for all targets:
|
|
25
|
-
'variables': {
|
|
26
|
-
# Source directory:
|
|
27
|
-
'src_dir': './src',
|
|
28
|
-
|
|
29
|
-
# Include directories:
|
|
30
|
-
'include_dirs': [
|
|
31
|
-
'<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).include; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
|
|
32
|
-
],
|
|
33
|
-
|
|
34
|
-
# Add-on destination directory:
|
|
35
|
-
'addon_output_dir': './src',
|
|
36
|
-
|
|
37
|
-
# Source files:
|
|
38
|
-
'src_files': [
|
|
39
|
-
'<(src_dir)/addon.cpp',
|
|
40
|
-
'<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).src; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
|
|
41
|
-
],
|
|
42
|
-
|
|
43
|
-
# Library dependencies:
|
|
44
|
-
'libraries': [
|
|
45
|
-
'<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libraries; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
|
|
46
|
-
],
|
|
47
|
-
|
|
48
|
-
# Library directories:
|
|
49
|
-
'library_dirs': [
|
|
50
|
-
'<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libpath; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
|
|
51
|
-
],
|
|
52
|
-
}, # end variables
|
|
53
|
-
}
|
package/src/addon.cpp
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
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/snanstdevpn.h"
|
|
20
|
-
#include <node_api.h>
|
|
21
|
-
#include <stdint.h>
|
|
22
|
-
#include <stdlib.h>
|
|
23
|
-
#include <stdbool.h>
|
|
24
|
-
#include <assert.h>
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Add-on namespace.
|
|
28
|
-
*/
|
|
29
|
-
namespace stdlib_stats_base_snanstdevpn {
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Computes the standard deviation of a single-precision floating-point strided array ignoring `NaN` values and using a two-pass algorithm.
|
|
33
|
-
*
|
|
34
|
-
* ## Notes
|
|
35
|
-
*
|
|
36
|
-
* - When called from JavaScript, the function expects four arguments:
|
|
37
|
-
*
|
|
38
|
-
* - `N`: number of indexed elements
|
|
39
|
-
* - `correction`: degrees of freedom adjustment
|
|
40
|
-
* - `X`: input array
|
|
41
|
-
* - `stride`: stride length
|
|
42
|
-
*/
|
|
43
|
-
napi_value node_snanstdevpn( napi_env env, napi_callback_info info ) {
|
|
44
|
-
napi_status status;
|
|
45
|
-
|
|
46
|
-
size_t argc = 4;
|
|
47
|
-
napi_value argv[ 4 ];
|
|
48
|
-
status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr );
|
|
49
|
-
assert( status == napi_ok );
|
|
50
|
-
|
|
51
|
-
if ( argc < 4 ) {
|
|
52
|
-
napi_throw_error( env, nullptr, "invalid invocation. Must provide 4 arguments." );
|
|
53
|
-
return nullptr;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
napi_valuetype vtype0;
|
|
57
|
-
status = napi_typeof( env, argv[ 0 ], &vtype0 );
|
|
58
|
-
assert( status == napi_ok );
|
|
59
|
-
if ( vtype0 != napi_number ) {
|
|
60
|
-
napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." );
|
|
61
|
-
return nullptr;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
napi_valuetype vtype1;
|
|
65
|
-
status = napi_typeof( env, argv[ 1 ], &vtype1 );
|
|
66
|
-
assert( status == napi_ok );
|
|
67
|
-
if ( vtype1 != napi_number ) {
|
|
68
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a number." );
|
|
69
|
-
return nullptr;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
bool res;
|
|
73
|
-
status = napi_is_typedarray( env, argv[ 2 ], &res );
|
|
74
|
-
assert( status == napi_ok );
|
|
75
|
-
if ( res == false ) {
|
|
76
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float32Array." );
|
|
77
|
-
return nullptr;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
napi_valuetype vtype3;
|
|
81
|
-
status = napi_typeof( env, argv[ 3 ], &vtype3 );
|
|
82
|
-
assert( status == napi_ok );
|
|
83
|
-
if ( vtype3 != napi_number ) {
|
|
84
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a number." );
|
|
85
|
-
return nullptr;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
int64_t N;
|
|
89
|
-
status = napi_get_value_int64( env, argv[ 0 ], &N );
|
|
90
|
-
assert( status == napi_ok );
|
|
91
|
-
|
|
92
|
-
double correction;
|
|
93
|
-
status = napi_get_value_double( env, argv[ 1 ], &correction );
|
|
94
|
-
assert( status == napi_ok );
|
|
95
|
-
|
|
96
|
-
int64_t stride;
|
|
97
|
-
status = napi_get_value_int64( env, argv[ 3 ], &stride );
|
|
98
|
-
assert( status == napi_ok );
|
|
99
|
-
|
|
100
|
-
napi_typedarray_type vtype2;
|
|
101
|
-
size_t xlen;
|
|
102
|
-
void *X;
|
|
103
|
-
status = napi_get_typedarray_info( env, argv[ 2 ], &vtype2, &xlen, &X, nullptr, nullptr );
|
|
104
|
-
assert( status == napi_ok );
|
|
105
|
-
if ( vtype2 != napi_float32_array ) {
|
|
106
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float32Array." );
|
|
107
|
-
return nullptr;
|
|
108
|
-
}
|
|
109
|
-
if ( (N-1)*llabs(stride) >= (int64_t)xlen ) {
|
|
110
|
-
napi_throw_range_error( env, nullptr, "invalid argument. Third argument has insufficient elements based on the associated stride and the number of indexed elements." );
|
|
111
|
-
return nullptr;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
napi_value v;
|
|
115
|
-
status = napi_create_double( env, (double)stdlib_strided_snanstdevpn( N, (float)correction, (float *)X, stride ), &v );
|
|
116
|
-
assert( status == napi_ok );
|
|
117
|
-
|
|
118
|
-
return v;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
napi_value Init( napi_env env, napi_value exports ) {
|
|
122
|
-
napi_status status;
|
|
123
|
-
napi_value fcn;
|
|
124
|
-
status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_snanstdevpn, NULL, &fcn );
|
|
125
|
-
assert( status == napi_ok );
|
|
126
|
-
return fcn;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
NAPI_MODULE( NODE_GYP_MODULE_NAME, Init )
|
|
130
|
-
} // end namespace stdlib_stats_base_snanstdevpn
|