@stdlib/stats-strided-snanmskrange 0.1.0
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/LICENSE +177 -0
- package/NOTICE +1 -0
- package/README.md +456 -0
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +107 -0
- package/include/stdlib/stats/strided/snanmskrange.h +46 -0
- package/lib/index.js +72 -0
- package/lib/main.js +35 -0
- package/lib/native.js +35 -0
- package/lib/ndarray.js +100 -0
- package/lib/ndarray.native.js +57 -0
- package/lib/snanmskrange.js +56 -0
- package/lib/snanmskrange.native.js +55 -0
- package/manifest.json +104 -0
- package/package.json +100 -0
- package/src/addon.c +67 -0
- package/src/main.c +97 -0
package/manifest.json
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
{
|
|
2
|
+
"options": {
|
|
3
|
+
"task": "build",
|
|
4
|
+
"wasm": false
|
|
5
|
+
},
|
|
6
|
+
"fields": [
|
|
7
|
+
{
|
|
8
|
+
"field": "src",
|
|
9
|
+
"resolve": true,
|
|
10
|
+
"relative": true
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"field": "include",
|
|
14
|
+
"resolve": true,
|
|
15
|
+
"relative": true
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"field": "libraries",
|
|
19
|
+
"resolve": false,
|
|
20
|
+
"relative": false
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"field": "libpath",
|
|
24
|
+
"resolve": true,
|
|
25
|
+
"relative": false
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"confs": [
|
|
29
|
+
{
|
|
30
|
+
"task": "build",
|
|
31
|
+
"wasm": false,
|
|
32
|
+
"src": [
|
|
33
|
+
"./src/main.c"
|
|
34
|
+
],
|
|
35
|
+
"include": [
|
|
36
|
+
"./include"
|
|
37
|
+
],
|
|
38
|
+
"libraries": [],
|
|
39
|
+
"libpath": [],
|
|
40
|
+
"dependencies": [
|
|
41
|
+
"@stdlib/blas-base-shared",
|
|
42
|
+
"@stdlib/math-base-assert-is-nanf",
|
|
43
|
+
"@stdlib/strided-base-stride2offset",
|
|
44
|
+
"@stdlib/napi-export",
|
|
45
|
+
"@stdlib/napi-argv",
|
|
46
|
+
"@stdlib/napi-argv-int64",
|
|
47
|
+
"@stdlib/napi-argv-strided-float32array",
|
|
48
|
+
"@stdlib/napi-argv-strided-uint8array",
|
|
49
|
+
"@stdlib/napi-create-double"
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"task": "benchmark",
|
|
54
|
+
"wasm": false,
|
|
55
|
+
"src": [
|
|
56
|
+
"./src/main.c"
|
|
57
|
+
],
|
|
58
|
+
"include": [
|
|
59
|
+
"./include"
|
|
60
|
+
],
|
|
61
|
+
"libraries": [],
|
|
62
|
+
"libpath": [],
|
|
63
|
+
"dependencies": [
|
|
64
|
+
"@stdlib/blas-base-shared",
|
|
65
|
+
"@stdlib/math-base-assert-is-nanf",
|
|
66
|
+
"@stdlib/strided-base-stride2offset"
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"task": "examples",
|
|
71
|
+
"wasm": false,
|
|
72
|
+
"src": [
|
|
73
|
+
"./src/main.c"
|
|
74
|
+
],
|
|
75
|
+
"include": [
|
|
76
|
+
"./include"
|
|
77
|
+
],
|
|
78
|
+
"libraries": [],
|
|
79
|
+
"libpath": [],
|
|
80
|
+
"dependencies": [
|
|
81
|
+
"@stdlib/blas-base-shared",
|
|
82
|
+
"@stdlib/math-base-assert-is-nanf",
|
|
83
|
+
"@stdlib/strided-base-stride2offset"
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"task": "",
|
|
88
|
+
"wasm": true,
|
|
89
|
+
"src": [
|
|
90
|
+
"./src/main.c"
|
|
91
|
+
],
|
|
92
|
+
"include": [
|
|
93
|
+
"./include"
|
|
94
|
+
],
|
|
95
|
+
"libraries": [],
|
|
96
|
+
"libpath": [],
|
|
97
|
+
"dependencies": [
|
|
98
|
+
"@stdlib/blas-base-shared",
|
|
99
|
+
"@stdlib/math-base-assert-is-nanf",
|
|
100
|
+
"@stdlib/strided-base-stride2offset"
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stdlib/stats-strided-snanmskrange",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Calculate the range of a single-precision floating-point strided array according to a mask, ignoring NaN values.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "The Stdlib Authors",
|
|
8
|
+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
|
9
|
+
},
|
|
10
|
+
"contributors": [
|
|
11
|
+
{
|
|
12
|
+
"name": "The Stdlib Authors",
|
|
13
|
+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"main": "./lib",
|
|
17
|
+
"browser": "./lib/main.js",
|
|
18
|
+
"gypfile": false,
|
|
19
|
+
"directories": {
|
|
20
|
+
"doc": "./docs",
|
|
21
|
+
"include": "./include",
|
|
22
|
+
"lib": "./lib",
|
|
23
|
+
"src": "./src",
|
|
24
|
+
"dist": "./dist"
|
|
25
|
+
},
|
|
26
|
+
"types": "./docs/types",
|
|
27
|
+
"scripts": {},
|
|
28
|
+
"homepage": "https://stdlib.io",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git://github.com/stdlib-js/stats-strided-snanmskrange.git"
|
|
32
|
+
},
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@stdlib/assert-is-error": "^0.2.2",
|
|
38
|
+
"@stdlib/blas-base-shared": "^0.2.0",
|
|
39
|
+
"@stdlib/math-base-assert-is-nanf": "^0.2.2",
|
|
40
|
+
"@stdlib/napi-argv": "^0.2.2",
|
|
41
|
+
"@stdlib/napi-argv-int64": "^0.2.2",
|
|
42
|
+
"@stdlib/napi-argv-strided-float32array": "^0.2.2",
|
|
43
|
+
"@stdlib/napi-argv-strided-uint8array": "^0.2.2",
|
|
44
|
+
"@stdlib/napi-create-double": "^0.0.2",
|
|
45
|
+
"@stdlib/napi-export": "^0.3.0",
|
|
46
|
+
"@stdlib/number-float64-base-to-float32": "^0.2.2",
|
|
47
|
+
"@stdlib/strided-base-stride2offset": "^0.1.0",
|
|
48
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
|
|
49
|
+
"@stdlib/utils-library-manifest": "^0.2.3",
|
|
50
|
+
"@stdlib/utils-try-require": "^0.2.2"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=0.10.0",
|
|
55
|
+
"npm": ">2.7.0"
|
|
56
|
+
},
|
|
57
|
+
"os": [
|
|
58
|
+
"aix",
|
|
59
|
+
"darwin",
|
|
60
|
+
"freebsd",
|
|
61
|
+
"linux",
|
|
62
|
+
"macos",
|
|
63
|
+
"openbsd",
|
|
64
|
+
"sunos",
|
|
65
|
+
"win32",
|
|
66
|
+
"windows"
|
|
67
|
+
],
|
|
68
|
+
"keywords": [
|
|
69
|
+
"stdlib",
|
|
70
|
+
"stdmath",
|
|
71
|
+
"statistics",
|
|
72
|
+
"stats",
|
|
73
|
+
"mathematics",
|
|
74
|
+
"math",
|
|
75
|
+
"maximum",
|
|
76
|
+
"max",
|
|
77
|
+
"minimum",
|
|
78
|
+
"min",
|
|
79
|
+
"range",
|
|
80
|
+
"extremes",
|
|
81
|
+
"dispersion",
|
|
82
|
+
"domain",
|
|
83
|
+
"extent",
|
|
84
|
+
"strided",
|
|
85
|
+
"strided array",
|
|
86
|
+
"masked",
|
|
87
|
+
"mask",
|
|
88
|
+
"masked array",
|
|
89
|
+
"typed",
|
|
90
|
+
"array",
|
|
91
|
+
"float32",
|
|
92
|
+
"float",
|
|
93
|
+
"single",
|
|
94
|
+
"float32array"
|
|
95
|
+
],
|
|
96
|
+
"funding": {
|
|
97
|
+
"type": "opencollective",
|
|
98
|
+
"url": "https://opencollective.com/stdlib"
|
|
99
|
+
}
|
|
100
|
+
}
|
package/src/addon.c
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
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/strided/snanmskrange.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_strided_float32array.h"
|
|
24
|
+
#include "stdlib/napi/argv_strided_uint8array.h"
|
|
25
|
+
#include "stdlib/napi/create_double.h"
|
|
26
|
+
#include "stdlib/blas/base/shared.h"
|
|
27
|
+
#include <node_api.h>
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Receives JavaScript callback invocation data.
|
|
31
|
+
*
|
|
32
|
+
* @param env environment under which the function is invoked
|
|
33
|
+
* @param info callback data
|
|
34
|
+
* @return Node-API value
|
|
35
|
+
*/
|
|
36
|
+
static napi_value addon( napi_env env, napi_callback_info info ) {
|
|
37
|
+
STDLIB_NAPI_ARGV( env, info, argv, argc, 5 );
|
|
38
|
+
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
|
|
39
|
+
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
|
|
40
|
+
STDLIB_NAPI_ARGV_INT64( env, strideMask, argv, 4 );
|
|
41
|
+
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 );
|
|
42
|
+
STDLIB_NAPI_ARGV_STRIDED_UINT8ARRAY( env, Mask, N, strideMask, argv, 3 );
|
|
43
|
+
STDLIB_NAPI_CREATE_DOUBLE( env, (double)API_SUFFIX(stdlib_strided_snanmskrange)( N, X, strideX, Mask, strideMask ), v );
|
|
44
|
+
return v;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Receives JavaScript callback invocation data.
|
|
49
|
+
*
|
|
50
|
+
* @param env environment under which the function is invoked
|
|
51
|
+
* @param info callback data
|
|
52
|
+
* @return Node-API value
|
|
53
|
+
*/
|
|
54
|
+
static napi_value addon_method( napi_env env, napi_callback_info info ) {
|
|
55
|
+
STDLIB_NAPI_ARGV( env, info, argv, argc, 7 );
|
|
56
|
+
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
|
|
57
|
+
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
|
|
58
|
+
STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 );
|
|
59
|
+
STDLIB_NAPI_ARGV_INT64( env, strideMask, argv, 5 );
|
|
60
|
+
STDLIB_NAPI_ARGV_INT64( env, offsetMask, argv, 6 );
|
|
61
|
+
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 );
|
|
62
|
+
STDLIB_NAPI_ARGV_STRIDED_UINT8ARRAY( env, Mask, N, strideMask, argv, 4 );
|
|
63
|
+
STDLIB_NAPI_CREATE_DOUBLE( env, (double)API_SUFFIX(stdlib_strided_snanmskrange_ndarray)( N, X, strideX, offsetX, Mask, strideMask, offsetMask ), v );
|
|
64
|
+
return v;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method )
|
package/src/main.c
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
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/strided/snanmskrange.h"
|
|
20
|
+
#include "stdlib/math/base/assert/is_nanf.h"
|
|
21
|
+
#include "stdlib/strided/base/stride2offset.h"
|
|
22
|
+
#include "stdlib/blas/base/shared.h"
|
|
23
|
+
#include <stdint.h>
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Computes the range of a single-precision floating-point strided array according to a mask, ignoring `NaN` values.
|
|
27
|
+
*
|
|
28
|
+
* @param N number of indexed elements
|
|
29
|
+
* @param X input array
|
|
30
|
+
* @param strideX X stride length
|
|
31
|
+
* @param Mask mask array
|
|
32
|
+
* @param strideMask Mask stride length
|
|
33
|
+
* @return output value
|
|
34
|
+
*/
|
|
35
|
+
float API_SUFFIX(stdlib_strided_snanmskrange)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const uint8_t *Mask, const CBLAS_INT strideMask ) {
|
|
36
|
+
const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
|
|
37
|
+
const CBLAS_INT om = stdlib_strided_stride2offset( N, strideMask );
|
|
38
|
+
return API_SUFFIX(stdlib_strided_snanmskrange_ndarray)( N, X, strideX, ox, Mask, strideMask, om );
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Computes the range of a single-precision floating-point strided array according to a mask, ignoring `NaN` values and using alternative indexing semantics.
|
|
43
|
+
*
|
|
44
|
+
* @param N number of indexed elements
|
|
45
|
+
* @param X input array
|
|
46
|
+
* @param strideX X stride length
|
|
47
|
+
* @param offsetX starting index for X
|
|
48
|
+
* @param Mask mask array
|
|
49
|
+
* @param strideMask Mask stride length
|
|
50
|
+
* @param offsetMask starting index for Mask
|
|
51
|
+
* @return output value
|
|
52
|
+
*/
|
|
53
|
+
float API_SUFFIX(stdlib_strided_snanmskrange_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const uint8_t *Mask, const CBLAS_INT strideMask, const CBLAS_INT offsetMask ) {
|
|
54
|
+
CBLAS_INT ix;
|
|
55
|
+
CBLAS_INT im;
|
|
56
|
+
CBLAS_INT i;
|
|
57
|
+
float max;
|
|
58
|
+
float min;
|
|
59
|
+
float v;
|
|
60
|
+
|
|
61
|
+
if ( N <= 0 ) {
|
|
62
|
+
return 0.0f / 0.0f; // NaN
|
|
63
|
+
}
|
|
64
|
+
ix = offsetX;
|
|
65
|
+
im = offsetMask;
|
|
66
|
+
for ( i = 0; i < N; i++ ) {
|
|
67
|
+
v = X[ ix ];
|
|
68
|
+
if ( v == v && Mask[ im ] == 0 ) {
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
ix += strideX;
|
|
72
|
+
im += strideMask;
|
|
73
|
+
}
|
|
74
|
+
if ( i == N ) {
|
|
75
|
+
return 0.0f / 0.0f; // NaN
|
|
76
|
+
}
|
|
77
|
+
min = v;
|
|
78
|
+
max = min;
|
|
79
|
+
i += 1;
|
|
80
|
+
for (; i < N; i++ ) {
|
|
81
|
+
ix += strideX;
|
|
82
|
+
im += strideMask;
|
|
83
|
+
if ( Mask[ im ] ) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
v = X[ ix ];
|
|
87
|
+
if ( stdlib_base_is_nanf( v ) ) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if ( v < min ) {
|
|
91
|
+
min = v;
|
|
92
|
+
} else if ( v > max ) {
|
|
93
|
+
max = v;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return max - min;
|
|
97
|
+
}
|