@stdlib/stats-base-snanvariance 0.2.2 → 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/snanvariance.h +0 -3
- package/manifest.json +81 -40
- package/package.json +12 -7
- package/src/addon.c +45 -0
- 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
|
@@ -243,10 +243,10 @@ console.log( v );
|
|
|
243
243
|
|
|
244
244
|
## See Also
|
|
245
245
|
|
|
246
|
-
- <span class="package-name">[`@stdlib/stats-
|
|
247
|
-
- <span class="package-name">[`@stdlib/stats-
|
|
246
|
+
- <span class="package-name">[`@stdlib/stats-strided/dnanvariance`][@stdlib/stats/strided/dnanvariance]</span><span class="delimiter">: </span><span class="description">calculate the variance of a double-precision floating-point strided array ignoring NaN values.</span>
|
|
247
|
+
- <span class="package-name">[`@stdlib/stats-strided/nanvariance`][@stdlib/stats/strided/nanvariance]</span><span class="delimiter">: </span><span class="description">calculate the variance of a strided array ignoring NaN values.</span>
|
|
248
248
|
- <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>
|
|
249
|
-
- <span class="package-name">[`@stdlib/stats-
|
|
249
|
+
- <span class="package-name">[`@stdlib/stats-strided/svariance`][@stdlib/stats/strided/svariance]</span><span class="delimiter">: </span><span class="description">calculate the variance of a single-precision floating-point strided array.</span>
|
|
250
250
|
|
|
251
251
|
</section>
|
|
252
252
|
|
|
@@ -278,7 +278,7 @@ See [LICENSE][stdlib-license].
|
|
|
278
278
|
|
|
279
279
|
## Copyright
|
|
280
280
|
|
|
281
|
-
Copyright © 2016-
|
|
281
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
282
282
|
|
|
283
283
|
</section>
|
|
284
284
|
|
|
@@ -291,8 +291,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
291
291
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-snanvariance.svg
|
|
292
292
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-base-snanvariance
|
|
293
293
|
|
|
294
|
-
[test-image]: https://github.com/stdlib-js/stats-base-snanvariance/actions/workflows/test.yml/badge.svg?branch=v0.2.
|
|
295
|
-
[test-url]: https://github.com/stdlib-js/stats-base-snanvariance/actions/workflows/test.yml?query=branch:v0.2.
|
|
294
|
+
[test-image]: https://github.com/stdlib-js/stats-base-snanvariance/actions/workflows/test.yml/badge.svg?branch=v0.2.3
|
|
295
|
+
[test-url]: https://github.com/stdlib-js/stats-base-snanvariance/actions/workflows/test.yml?query=branch:v0.2.3
|
|
296
296
|
|
|
297
297
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-snanvariance/main.svg
|
|
298
298
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-base-snanvariance?branch=main
|
|
@@ -304,8 +304,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
304
304
|
|
|
305
305
|
-->
|
|
306
306
|
|
|
307
|
-
[chat-image]: https://img.shields.io/
|
|
308
|
-
[chat-url]: https://
|
|
307
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
308
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
309
309
|
|
|
310
310
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
311
311
|
|
|
@@ -332,13 +332,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
332
332
|
|
|
333
333
|
<!-- <related-links> -->
|
|
334
334
|
|
|
335
|
-
[@stdlib/stats/
|
|
335
|
+
[@stdlib/stats/strided/dnanvariance]: https://www.npmjs.com/package/@stdlib/stats-strided-dnanvariance
|
|
336
336
|
|
|
337
|
-
[@stdlib/stats/
|
|
337
|
+
[@stdlib/stats/strided/nanvariance]: https://www.npmjs.com/package/@stdlib/stats-strided-nanvariance
|
|
338
338
|
|
|
339
339
|
[@stdlib/stats/base/snanstdev]: https://www.npmjs.com/package/@stdlib/stats-base-snanstdev
|
|
340
340
|
|
|
341
|
-
[@stdlib/stats/
|
|
341
|
+
[@stdlib/stats/strided/svariance]: https://www.npmjs.com/package/@stdlib/stats-strided-svariance
|
|
342
342
|
|
|
343
343
|
<!-- </related-links> -->
|
|
344
344
|
|
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/snanvariance.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/snanvariance.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/snanvariance.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-snanvariance",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Calculate the variance of a single-precision floating-point strided array ignoring NaN values.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -34,11 +34,17 @@
|
|
|
34
34
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@stdlib/assert-is-error": "^0.2.
|
|
38
|
-
"@stdlib/
|
|
39
|
-
"@stdlib/
|
|
40
|
-
"@stdlib/
|
|
41
|
-
"@stdlib/
|
|
37
|
+
"@stdlib/assert-is-error": "^0.2.3",
|
|
38
|
+
"@stdlib/napi-argv": "^0.2.3",
|
|
39
|
+
"@stdlib/napi-argv-float": "^0.2.3",
|
|
40
|
+
"@stdlib/napi-argv-int64": "^0.2.3",
|
|
41
|
+
"@stdlib/napi-argv-strided-float32array": "^0.2.3",
|
|
42
|
+
"@stdlib/napi-create-double": "^0.0.3",
|
|
43
|
+
"@stdlib/napi-export": "^0.3.1",
|
|
44
|
+
"@stdlib/stats-base-snanvariancepn": "^0.2.2",
|
|
45
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3",
|
|
46
|
+
"@stdlib/utils-library-manifest": "^0.2.4",
|
|
47
|
+
"@stdlib/utils-try-require": "^0.2.3"
|
|
42
48
|
},
|
|
43
49
|
"devDependencies": {},
|
|
44
50
|
"engines": {
|
|
@@ -81,7 +87,6 @@
|
|
|
81
87
|
"single",
|
|
82
88
|
"float32array"
|
|
83
89
|
],
|
|
84
|
-
"__stdlib__": {},
|
|
85
90
|
"funding": {
|
|
86
91
|
"type": "opencollective",
|
|
87
92
|
"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/snanvariance.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_snanvariance( N, correction, X, stride ), v );
|
|
42
|
+
return v;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
STDLIB_NAPI_MODULE_EXPORT_FCN( addon )
|
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/snanvariance.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_snanvariance {
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Computes the variance of a single-precision floating-point strided array ignoring `NaN` values.
|
|
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_snanvariance( 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_snanvariance( 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_snanvariance, 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_snanvariance
|