@stdlib/stats-base-snanvariancech 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 CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2024 The Stdlib Authors.
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md CHANGED
@@ -253,11 +253,11 @@ console.log( v );
253
253
 
254
254
  ## See Also
255
255
 
256
- - <span class="package-name">[`@stdlib/stats-base/dnanvariancech`][@stdlib/stats/base/dnanvariancech]</span><span class="delimiter">: </span><span class="description">calculate the variance of a double-precision floating-point strided array ignoring NaN values and using a one-pass trial mean algorithm.</span>
257
- - <span class="package-name">[`@stdlib/stats-base/nanvariancech`][@stdlib/stats/base/nanvariancech]</span><span class="delimiter">: </span><span class="description">calculate the variance of a strided array ignoring NaN values and using a one-pass trial mean algorithm.</span>
256
+ - <span class="package-name">[`@stdlib/stats-strided/dnanvariancech`][@stdlib/stats/strided/dnanvariancech]</span><span class="delimiter">: </span><span class="description">calculate the variance of a double-precision floating-point strided array ignoring NaN values and using a one-pass trial mean algorithm.</span>
257
+ - <span class="package-name">[`@stdlib/stats-strided/nanvariancech`][@stdlib/stats/strided/nanvariancech]</span><span class="delimiter">: </span><span class="description">calculate the variance of a strided array ignoring NaN values and using a one-pass trial mean algorithm.</span>
258
258
  - <span class="package-name">[`@stdlib/stats-base/snanstdevch`][@stdlib/stats/base/snanstdevch]</span><span class="delimiter">: </span><span class="description">calculate the standard deviation of a single-precision floating-point strided array ignoring NaN values and using a one-pass trial mean algorithm.</span>
259
259
  - <span class="package-name">[`@stdlib/stats-base/snanvariance`][@stdlib/stats/base/snanvariance]</span><span class="delimiter">: </span><span class="description">calculate the variance of a single-precision floating-point strided array ignoring NaN values.</span>
260
- - <span class="package-name">[`@stdlib/stats-base/svariancech`][@stdlib/stats/base/svariancech]</span><span class="delimiter">: </span><span class="description">calculate the variance of a single-precision floating-point strided array using a one-pass trial mean algorithm.</span>
260
+ - <span class="package-name">[`@stdlib/stats-strided/svariancech`][@stdlib/stats/strided/svariancech]</span><span class="delimiter">: </span><span class="description">calculate the variance of a single-precision floating-point strided array using a one-pass trial mean algorithm.</span>
261
261
 
262
262
  </section>
263
263
 
@@ -289,7 +289,7 @@ See [LICENSE][stdlib-license].
289
289
 
290
290
  ## Copyright
291
291
 
292
- Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
292
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
293
293
 
294
294
  </section>
295
295
 
@@ -302,8 +302,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
302
302
  [npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-snanvariancech.svg
303
303
  [npm-url]: https://npmjs.org/package/@stdlib/stats-base-snanvariancech
304
304
 
305
- [test-image]: https://github.com/stdlib-js/stats-base-snanvariancech/actions/workflows/test.yml/badge.svg?branch=v0.2.1
306
- [test-url]: https://github.com/stdlib-js/stats-base-snanvariancech/actions/workflows/test.yml?query=branch:v0.2.1
305
+ [test-image]: https://github.com/stdlib-js/stats-base-snanvariancech/actions/workflows/test.yml/badge.svg?branch=v0.2.3
306
+ [test-url]: https://github.com/stdlib-js/stats-base-snanvariancech/actions/workflows/test.yml?query=branch:v0.2.3
307
307
 
308
308
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-snanvariancech/main.svg
309
309
  [coverage-url]: https://codecov.io/github/stdlib-js/stats-base-snanvariancech?branch=main
@@ -315,8 +315,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
315
315
 
316
316
  -->
317
317
 
318
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
319
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
318
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
319
+ [chat-url]: https://stdlib.zulipchat.com
320
320
 
321
321
  [stdlib]: https://github.com/stdlib-js/stdlib
322
322
 
@@ -351,15 +351,15 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
351
351
 
352
352
  <!-- <related-links> -->
353
353
 
354
- [@stdlib/stats/base/dnanvariancech]: https://www.npmjs.com/package/@stdlib/stats-base-dnanvariancech
354
+ [@stdlib/stats/strided/dnanvariancech]: https://www.npmjs.com/package/@stdlib/stats-strided-dnanvariancech
355
355
 
356
- [@stdlib/stats/base/nanvariancech]: https://www.npmjs.com/package/@stdlib/stats-base-nanvariancech
356
+ [@stdlib/stats/strided/nanvariancech]: https://www.npmjs.com/package/@stdlib/stats-strided-nanvariancech
357
357
 
358
358
  [@stdlib/stats/base/snanstdevch]: https://www.npmjs.com/package/@stdlib/stats-base-snanstdevch
359
359
 
360
360
  [@stdlib/stats/base/snanvariance]: https://www.npmjs.com/package/@stdlib/stats-base-snanvariance
361
361
 
362
- [@stdlib/stats/base/svariancech]: https://www.npmjs.com/package/@stdlib/stats-base-svariancech
362
+ [@stdlib/stats/strided/svariancech]: https://www.npmjs.com/package/@stdlib/stats-strided-svariancech
363
363
 
364
364
  <!-- </related-links> -->
365
365
 
@@ -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_SNANVARIANCECH_H
23
20
  #define STDLIB_STATS_BASE_SNANVARIANCECH_H
24
21
 
package/manifest.json CHANGED
@@ -1,40 +1,78 @@
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/snanvariancech.c"
29
- ],
30
- "include": [
31
- "./include"
32
- ],
33
- "libraries": [
34
- "-lm"
35
- ],
36
- "libpath": [],
37
- "dependencies": []
38
- }
39
- ]
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/snanvariancech.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/napi-create-double"
47
+ ]
48
+ },
49
+ {
50
+ "task": "benchmark",
51
+ "src": [
52
+ "./src/snanvariancech.c"
53
+ ],
54
+ "include": [
55
+ "./include"
56
+ ],
57
+ "libraries": [
58
+ "-lm"
59
+ ],
60
+ "libpath": [],
61
+ "dependencies": []
62
+ },
63
+ {
64
+ "task": "examples",
65
+ "src": [
66
+ "./src/snanvariancech.c"
67
+ ],
68
+ "include": [
69
+ "./include"
70
+ ],
71
+ "libraries": [
72
+ "-lm"
73
+ ],
74
+ "libpath": [],
75
+ "dependencies": []
76
+ }
77
+ ]
40
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/stats-base-snanvariancech",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Calculate the variance of a single-precision floating-point strided array ignoring NaN values and using a one-pass trial mean algorithm.",
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.1",
38
- "@stdlib/number-float64-base-to-float32": "^0.2.1",
39
- "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1",
40
- "@stdlib/utils-library-manifest": "^0.2.1",
41
- "@stdlib/utils-try-require": "^0.2.1"
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/number-float64-base-to-float32": "^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/snanvariancech.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_snanvariancech( 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/snanvariancech.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_snanvariancech {
30
-
31
- /**
32
- * Computes the variance of a single-precision floating-point strided array ignoring `NaN` values and using a one-pass trial mean 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_snanvariancech( 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_snanvariancech( 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_snanvariancech, 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_snanvariancech