@stdlib/stats-strided-scuminabs 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 +426 -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 +103 -0
- package/include/stdlib/stats/strided/scuminabs.h +45 -0
- package/lib/index.js +70 -0
- package/lib/main.js +35 -0
- package/lib/native.js +35 -0
- package/lib/ndarray.js +95 -0
- package/lib/ndarray.native.js +57 -0
- package/lib/scuminabs.js +57 -0
- package/lib/scuminabs.native.js +55 -0
- package/manifest.json +106 -0
- package/package.json +97 -0
- package/src/addon.c +65 -0
- package/src/main.c +91 -0
package/package.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stdlib/stats-strided-scuminabs",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Calculate the cumulative minimum absolute value of single-precision floating-point strided array elements.",
|
|
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-scuminabs.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.1.0",
|
|
39
|
+
"@stdlib/math-base-assert-is-nanf": "^0.2.2",
|
|
40
|
+
"@stdlib/math-base-special-absf": "^0.2.2",
|
|
41
|
+
"@stdlib/napi-argv": "^0.2.2",
|
|
42
|
+
"@stdlib/napi-argv-int64": "^0.2.2",
|
|
43
|
+
"@stdlib/napi-argv-strided-float32array": "^0.2.2",
|
|
44
|
+
"@stdlib/napi-export": "^0.3.0",
|
|
45
|
+
"@stdlib/strided-base-stride2offset": "^0.1.0",
|
|
46
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
|
|
47
|
+
"@stdlib/utils-library-manifest": "^0.2.3",
|
|
48
|
+
"@stdlib/utils-try-require": "^0.2.2"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=0.10.0",
|
|
53
|
+
"npm": ">2.7.0"
|
|
54
|
+
},
|
|
55
|
+
"os": [
|
|
56
|
+
"aix",
|
|
57
|
+
"darwin",
|
|
58
|
+
"freebsd",
|
|
59
|
+
"linux",
|
|
60
|
+
"macos",
|
|
61
|
+
"openbsd",
|
|
62
|
+
"sunos",
|
|
63
|
+
"win32",
|
|
64
|
+
"windows"
|
|
65
|
+
],
|
|
66
|
+
"keywords": [
|
|
67
|
+
"stdlib",
|
|
68
|
+
"stdmath",
|
|
69
|
+
"statistics",
|
|
70
|
+
"stats",
|
|
71
|
+
"mathematics",
|
|
72
|
+
"math",
|
|
73
|
+
"minimum",
|
|
74
|
+
"min",
|
|
75
|
+
"abs",
|
|
76
|
+
"absolute",
|
|
77
|
+
"absolute value",
|
|
78
|
+
"range",
|
|
79
|
+
"extremes",
|
|
80
|
+
"domain",
|
|
81
|
+
"extent",
|
|
82
|
+
"accumulate",
|
|
83
|
+
"cumulative",
|
|
84
|
+
"strided",
|
|
85
|
+
"strided array",
|
|
86
|
+
"typed",
|
|
87
|
+
"array",
|
|
88
|
+
"float32",
|
|
89
|
+
"float",
|
|
90
|
+
"single",
|
|
91
|
+
"float32array"
|
|
92
|
+
],
|
|
93
|
+
"funding": {
|
|
94
|
+
"type": "opencollective",
|
|
95
|
+
"url": "https://opencollective.com/stdlib"
|
|
96
|
+
}
|
|
97
|
+
}
|
package/src/addon.c
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
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/scuminabs.h"
|
|
20
|
+
#include "stdlib/blas/base/shared.h"
|
|
21
|
+
#include "stdlib/napi/export.h"
|
|
22
|
+
#include "stdlib/napi/argv.h"
|
|
23
|
+
#include "stdlib/napi/argv_int64.h"
|
|
24
|
+
#include "stdlib/napi/argv_strided_float32array.h"
|
|
25
|
+
#include <node_api.h>
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Receives JavaScript callback invocation data.
|
|
29
|
+
*
|
|
30
|
+
* @param env environment under which the function is invoked
|
|
31
|
+
* @param info callback data
|
|
32
|
+
* @return Node-API value
|
|
33
|
+
*/
|
|
34
|
+
static napi_value addon( napi_env env, napi_callback_info info ) {
|
|
35
|
+
STDLIB_NAPI_ARGV( env, info, argv, argc, 5 );
|
|
36
|
+
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
|
|
37
|
+
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
|
|
38
|
+
STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 4 );
|
|
39
|
+
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 );
|
|
40
|
+
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 3 );
|
|
41
|
+
API_SUFFIX(stdlib_strided_scuminabs)( N, X, strideX, Y, strideY );
|
|
42
|
+
return NULL;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Receives JavaScript callback invocation data.
|
|
47
|
+
*
|
|
48
|
+
* @param env environment under which the function is invoked
|
|
49
|
+
* @param info callback data
|
|
50
|
+
* @return Node-API value
|
|
51
|
+
*/
|
|
52
|
+
static napi_value addon_method( napi_env env, napi_callback_info info ) {
|
|
53
|
+
STDLIB_NAPI_ARGV( env, info, argv, argc, 7 );
|
|
54
|
+
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
|
|
55
|
+
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
|
|
56
|
+
STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 );
|
|
57
|
+
STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 );
|
|
58
|
+
STDLIB_NAPI_ARGV_INT64( env, offsetY, argv, 6 );
|
|
59
|
+
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 );
|
|
60
|
+
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 4 );
|
|
61
|
+
API_SUFFIX(stdlib_strided_scuminabs_ndarray)( N, X, strideX, offsetX, Y, strideY, offsetY );
|
|
62
|
+
return NULL;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method )
|
package/src/main.c
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
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/scuminabs.h"
|
|
20
|
+
#include "stdlib/math/base/assert/is_nanf.h"
|
|
21
|
+
#include "stdlib/math/base/special/absf.h"
|
|
22
|
+
#include "stdlib/blas/base/shared.h"
|
|
23
|
+
#include "stdlib/strided/base/stride2offset.h"
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Computes the cumulative minimum absolute value of single-precision floating-point strided array elements.
|
|
27
|
+
*
|
|
28
|
+
* @param N number of indexed elements
|
|
29
|
+
* @param X input array
|
|
30
|
+
* @param strideX X stride length
|
|
31
|
+
* @param Y output array
|
|
32
|
+
* @param strideY Y stride length
|
|
33
|
+
*/
|
|
34
|
+
void stdlib_strided_scuminabs( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY ) {
|
|
35
|
+
const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
|
|
36
|
+
const CBLAS_INT oy = stdlib_strided_stride2offset( N, strideY );
|
|
37
|
+
API_SUFFIX(stdlib_strided_scuminabs_ndarray)( N, X, strideX, ox, Y, strideY, oy );
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Computes the cumulative minimum absolute value of single-precision floating-point strided array elements 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 Y output array
|
|
49
|
+
* @param strideY Y stride length
|
|
50
|
+
* @param offsetY starting index for Y
|
|
51
|
+
*/
|
|
52
|
+
void API_SUFFIX(stdlib_strided_scuminabs_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) {
|
|
53
|
+
CBLAS_INT ix;
|
|
54
|
+
CBLAS_INT iy;
|
|
55
|
+
CBLAS_INT i;
|
|
56
|
+
float min;
|
|
57
|
+
float v;
|
|
58
|
+
|
|
59
|
+
if ( N <= 0 ) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
ix = offsetX;
|
|
63
|
+
iy = offsetY;
|
|
64
|
+
min = stdlib_base_absf( X[ ix ] );
|
|
65
|
+
Y[ iy ] = min;
|
|
66
|
+
|
|
67
|
+
iy += strideY;
|
|
68
|
+
i = 1;
|
|
69
|
+
if ( !stdlib_base_is_nanf( min ) ) {
|
|
70
|
+
for (; i < N; i++ ) {
|
|
71
|
+
ix += strideX;
|
|
72
|
+
v = stdlib_base_absf( X[ ix ] );
|
|
73
|
+
if ( stdlib_base_is_nanf( v ) ) {
|
|
74
|
+
min = v;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
if ( v < min ) {
|
|
78
|
+
min = v;
|
|
79
|
+
}
|
|
80
|
+
Y[ iy ] = min;
|
|
81
|
+
iy += strideY;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if ( stdlib_base_is_nanf( min ) ) {
|
|
85
|
+
for (; i < N; i++ ) {
|
|
86
|
+
Y[ iy ] = min;
|
|
87
|
+
iy += strideY;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return;
|
|
91
|
+
}
|