@stdlib/stats-base-snanstdevyc 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 CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2024 The Stdlib Authors.
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md CHANGED
@@ -249,11 +249,11 @@ console.log( v );
249
249
 
250
250
  ## See Also
251
251
 
252
- - <span class="package-name">[`@stdlib/stats-base/dnanstdevyc`][@stdlib/stats/base/dnanstdevyc]</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 one-pass algorithm proposed by Youngs and Cramer.</span>
253
- - <span class="package-name">[`@stdlib/stats-base/nanstdevyc`][@stdlib/stats/base/nanstdevyc]</span><span class="delimiter">: </span><span class="description">calculate the standard deviation of a strided array ignoring NaN values and using a one-pass algorithm proposed by Youngs and Cramer.</span>
252
+ - <span class="package-name">[`@stdlib/stats-strided/dnanstdevyc`][@stdlib/stats/strided/dnanstdevyc]</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 one-pass algorithm proposed by Youngs and Cramer.</span>
253
+ - <span class="package-name">[`@stdlib/stats-strided/nanstdevyc`][@stdlib/stats/strided/nanstdevyc]</span><span class="delimiter">: </span><span class="description">calculate the standard deviation of a strided array ignoring NaN values and using a one-pass algorithm proposed by Youngs and Cramer.</span>
254
254
  - <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>
255
255
  - <span class="package-name">[`@stdlib/stats-base/snanvarianceyc`][@stdlib/stats/base/snanvarianceyc]</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 one-pass algorithm proposed by Youngs and Cramer.</span>
256
- - <span class="package-name">[`@stdlib/stats-base/sstdevyc`][@stdlib/stats/base/sstdevyc]</span><span class="delimiter">: </span><span class="description">calculate the standard deviation of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer.</span>
256
+ - <span class="package-name">[`@stdlib/stats-strided/sstdevyc`][@stdlib/stats/strided/sstdevyc]</span><span class="delimiter">: </span><span class="description">calculate the standard deviation of a single-precision floating-point strided array using a one-pass algorithm proposed by Youngs and Cramer.</span>
257
257
 
258
258
  </section>
259
259
 
@@ -285,7 +285,7 @@ See [LICENSE][stdlib-license].
285
285
 
286
286
  ## Copyright
287
287
 
288
- Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
288
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
289
289
 
290
290
  </section>
291
291
 
@@ -298,8 +298,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
298
298
  [npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-snanstdevyc.svg
299
299
  [npm-url]: https://npmjs.org/package/@stdlib/stats-base-snanstdevyc
300
300
 
301
- [test-image]: https://github.com/stdlib-js/stats-base-snanstdevyc/actions/workflows/test.yml/badge.svg?branch=v0.2.2
302
- [test-url]: https://github.com/stdlib-js/stats-base-snanstdevyc/actions/workflows/test.yml?query=branch:v0.2.2
301
+ [test-image]: https://github.com/stdlib-js/stats-base-snanstdevyc/actions/workflows/test.yml/badge.svg?branch=v0.2.3
302
+ [test-url]: https://github.com/stdlib-js/stats-base-snanstdevyc/actions/workflows/test.yml?query=branch:v0.2.3
303
303
 
304
304
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-snanstdevyc/main.svg
305
305
  [coverage-url]: https://codecov.io/github/stdlib-js/stats-base-snanstdevyc?branch=main
@@ -311,8 +311,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
311
311
 
312
312
  -->
313
313
 
314
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
315
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
314
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
315
+ [chat-url]: https://stdlib.zulipchat.com
316
316
 
317
317
  [stdlib]: https://github.com/stdlib-js/stdlib
318
318
 
@@ -341,15 +341,15 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
341
341
 
342
342
  <!-- <related-links> -->
343
343
 
344
- [@stdlib/stats/base/dnanstdevyc]: https://www.npmjs.com/package/@stdlib/stats-base-dnanstdevyc
344
+ [@stdlib/stats/strided/dnanstdevyc]: https://www.npmjs.com/package/@stdlib/stats-strided-dnanstdevyc
345
345
 
346
- [@stdlib/stats/base/nanstdevyc]: https://www.npmjs.com/package/@stdlib/stats-base-nanstdevyc
346
+ [@stdlib/stats/strided/nanstdevyc]: https://www.npmjs.com/package/@stdlib/stats-strided-nanstdevyc
347
347
 
348
348
  [@stdlib/stats/base/snanstdev]: https://www.npmjs.com/package/@stdlib/stats-base-snanstdev
349
349
 
350
350
  [@stdlib/stats/base/snanvarianceyc]: https://www.npmjs.com/package/@stdlib/stats-base-snanvarianceyc
351
351
 
352
- [@stdlib/stats/base/sstdevyc]: https://www.npmjs.com/package/@stdlib/stats-base-sstdevyc
352
+ [@stdlib/stats/strided/sstdevyc]: https://www.npmjs.com/package/@stdlib/stats-strided-sstdevyc
353
353
 
354
354
  <!-- </related-links> -->
355
355
 
@@ -16,9 +16,6 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- /**
20
- * Header file containing function declarations.
21
- */
22
19
  #ifndef STDLIB_STATS_BASE_SNANSTDEVYC_H
23
20
  #define STDLIB_STATS_BASE_SNANSTDEVYC_H
24
21
 
package/manifest.json CHANGED
@@ -1,42 +1,83 @@
1
1
  {
2
- "options": {},
3
- "fields": [
4
- {
5
- "field": "src",
6
- "resolve": true,
7
- "relative": true
8
- },
9
- {
10
- "field": "include",
11
- "resolve": true,
12
- "relative": true
13
- },
14
- {
15
- "field": "libraries",
16
- "resolve": false,
17
- "relative": false
18
- },
19
- {
20
- "field": "libpath",
21
- "resolve": true,
22
- "relative": false
23
- }
24
- ],
25
- "confs": [
26
- {
27
- "src": [
28
- "./src/snanstdevyc.c"
29
- ],
30
- "include": [
31
- "./include"
32
- ],
33
- "libraries": [
34
- "-lm"
35
- ],
36
- "libpath": [],
37
- "dependencies": [
38
- "@stdlib/stats-base-snanvarianceyc"
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/snanstdevyc.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-snanvarianceyc",
47
+ "@stdlib/napi-create-double"
48
+ ]
49
+ },
50
+ {
51
+ "task": "benchmark",
52
+ "src": [
53
+ "./src/snanstdevyc.c"
54
+ ],
55
+ "include": [
56
+ "./include"
57
+ ],
58
+ "libraries": [
59
+ "-lm"
60
+ ],
61
+ "libpath": [],
62
+ "dependencies": [
63
+ "@stdlib/stats-base-snanvarianceyc"
64
+ ]
65
+ },
66
+ {
67
+ "task": "examples",
68
+ "src": [
69
+ "./src/snanstdevyc.c"
70
+ ],
71
+ "include": [
72
+ "./include"
73
+ ],
74
+ "libraries": [
75
+ "-lm"
76
+ ],
77
+ "libpath": [],
78
+ "dependencies": [
79
+ "@stdlib/stats-base-snanvarianceyc"
80
+ ]
81
+ }
82
+ ]
42
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/stats-base-snanstdevyc",
3
- "version": "0.2.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 one-pass algorithm proposed by Youngs and Cramer.",
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.2",
38
- "@stdlib/math-base-special-sqrt": "^0.2.1",
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",
39
45
  "@stdlib/number-float64-base-to-float32": "^0.2.2",
40
- "@stdlib/stats-base-snanvarianceyc": "^0.2.2",
41
- "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
42
- "@stdlib/utils-library-manifest": "^0.2.2",
43
- "@stdlib/utils-try-require": "^0.2.2"
46
+ "@stdlib/stats-base-snanvarianceyc": "^0.2.3",
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/snanstdevyc.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_snanstdevyc( 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/snanstdevyc.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_snanstdevyc {
30
-
31
- /**
32
- * Computes the standard deviation of a single-precision floating-point strided array ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer.
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_snanstdevyc( 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_snanstdevyc( 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_snanstdevyc, 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_snanstdevyc