@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
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
// TypeScript Version: 4.1
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Interface describing `scuminabs`.
|
|
23
|
+
*/
|
|
24
|
+
interface Routine {
|
|
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
|
+
* @returns output array
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
37
|
+
*
|
|
38
|
+
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
39
|
+
* var y = new Float32Array( x.length );
|
|
40
|
+
*
|
|
41
|
+
* scuminabs( x.length, x, 1, y, 1 );
|
|
42
|
+
* // y => <Float32Array>[ 1.0, 1.0, 1.0 ]
|
|
43
|
+
*/
|
|
44
|
+
( N: number, x: Float32Array, strideX: number, y: Float32Array, strideY: number ): Float32Array;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Computes the cumulative minimum absolute value of single-precision floating-point strided array elements using alternative indexing semantics.
|
|
48
|
+
*
|
|
49
|
+
* @param N - number of indexed elements
|
|
50
|
+
* @param x - input array
|
|
51
|
+
* @param strideX - `x` stride length
|
|
52
|
+
* @param offsetX - starting index for `x`
|
|
53
|
+
* @param y - output array
|
|
54
|
+
* @param strideY - `y` stride length
|
|
55
|
+
* @param offsetY - starting index for `y`
|
|
56
|
+
* @returns output array
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
60
|
+
*
|
|
61
|
+
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
62
|
+
* var y = new Float32Array( x.length );
|
|
63
|
+
*
|
|
64
|
+
* scuminabs.ndarray( x.length, x, 1, 0, y, 1, 0 );
|
|
65
|
+
* // y => <Float32Array>[ 1.0, 1.0, 1.0 ]
|
|
66
|
+
*/
|
|
67
|
+
ndarray( N: number, x: Float32Array, strideX: number, offsetX: number, y: Float32Array, strideY: number, offsetY: number ): Float32Array;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Computes the cumulative minimum absolute value of single-precision floating-point strided array elements.
|
|
72
|
+
*
|
|
73
|
+
* @param N - number of indexed elements
|
|
74
|
+
* @param x - input array
|
|
75
|
+
* @param strideX - `x` stride length
|
|
76
|
+
* @param y - output array
|
|
77
|
+
* @param strideY - `y` stride length
|
|
78
|
+
* @returns output array
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
82
|
+
*
|
|
83
|
+
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
84
|
+
* var y = new Float32Array( x.length );
|
|
85
|
+
*
|
|
86
|
+
* scuminabs( x.length, x, 1, y, 1 );
|
|
87
|
+
* // y => <Float32Array>[ 1.0, 1.0, 1.0 ]
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
91
|
+
*
|
|
92
|
+
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
93
|
+
* var y = new Float32Array( x.length );
|
|
94
|
+
*
|
|
95
|
+
* scuminabs.ndarray( x.length, x, 1, 0, y, 1, 0 );
|
|
96
|
+
* // y => <Float32Array>[ 1.0, 1.0, 1.0 ]
|
|
97
|
+
*/
|
|
98
|
+
declare var scuminabs: Routine;
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
// EXPORTS //
|
|
102
|
+
|
|
103
|
+
export = scuminabs;
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
#ifndef STDLIB_STATS_STRIDED_SCUMINABS_H
|
|
20
|
+
#define STDLIB_STATS_STRIDED_SCUMINABS_H
|
|
21
|
+
|
|
22
|
+
#include "stdlib/blas/base/shared.h"
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
26
|
+
*/
|
|
27
|
+
#ifdef __cplusplus
|
|
28
|
+
extern "C" {
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Computes the cumulative minimum absolute value of single-precision floating-point strided array elements.
|
|
33
|
+
*/
|
|
34
|
+
void API_SUFFIX(stdlib_strided_scuminabs)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY );
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Computes the cumulative minimum absolute value of single-precision floating-point strided array elements using alternative indexing semantics.
|
|
38
|
+
*/
|
|
39
|
+
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 );
|
|
40
|
+
|
|
41
|
+
#ifdef __cplusplus
|
|
42
|
+
}
|
|
43
|
+
#endif
|
|
44
|
+
|
|
45
|
+
#endif // !STDLIB_STATS_STRIDED_SCUMINABS_H
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Compute the cumulative minimum absolute value of single-precision floating-point strided array elements.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/stats-strided-scuminabs
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
28
|
+
* var scuminabs = require( '@stdlib/stats-strided-scuminabs' );
|
|
29
|
+
*
|
|
30
|
+
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
31
|
+
* var y = new Float32Array( x.length );
|
|
32
|
+
*
|
|
33
|
+
* scuminabs( x.length, x, 1, y, 1 );
|
|
34
|
+
* // y => <Float32Array>[ 1.0, 1.0, 1.0 ]
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
38
|
+
* var scuminabs = require( '@stdlib/stats-strided-scuminabs' );
|
|
39
|
+
*
|
|
40
|
+
* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
|
|
41
|
+
* var y = new Float32Array( x.length );
|
|
42
|
+
*
|
|
43
|
+
* scuminabs.ndarray( 4, x, 2, 1, y, 1, 0 );
|
|
44
|
+
* // y => <Float32Array>[ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
// MODULES //
|
|
48
|
+
|
|
49
|
+
var join = require( 'path' ).join;
|
|
50
|
+
var tryRequire = require( '@stdlib/utils-try-require' );
|
|
51
|
+
var isError = require( '@stdlib/assert-is-error' );
|
|
52
|
+
var main = require( './main.js' );
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
// MAIN //
|
|
56
|
+
|
|
57
|
+
var scuminabs;
|
|
58
|
+
var tmp = tryRequire( join( __dirname, './native.js' ) );
|
|
59
|
+
if ( isError( tmp ) ) {
|
|
60
|
+
scuminabs = main;
|
|
61
|
+
} else {
|
|
62
|
+
scuminabs = tmp;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
// EXPORTS //
|
|
67
|
+
|
|
68
|
+
module.exports = scuminabs;
|
|
69
|
+
|
|
70
|
+
// exports: { "ndarray": "scuminabs.ndarray" }
|
package/lib/main.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
|
|
24
|
+
var scuminabs = require( './scuminabs.js' );
|
|
25
|
+
var ndarray = require( './ndarray.js' );
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
// MAIN //
|
|
29
|
+
|
|
30
|
+
setReadOnly( scuminabs, 'ndarray', ndarray );
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// EXPORTS //
|
|
34
|
+
|
|
35
|
+
module.exports = scuminabs;
|
package/lib/native.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
|
|
24
|
+
var scuminabs = require( './scuminabs.native.js' );
|
|
25
|
+
var ndarray = require( './ndarray.native.js' );
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
// MAIN //
|
|
29
|
+
|
|
30
|
+
setReadOnly( scuminabs, 'ndarray', ndarray );
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// EXPORTS //
|
|
34
|
+
|
|
35
|
+
module.exports = scuminabs;
|
package/lib/ndarray.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var isnanf = require( '@stdlib/math-base-assert-is-nanf' );
|
|
24
|
+
var absf = require( '@stdlib/math-base-special-absf' );
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// MAIN //
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Computes the cumulative minimum absolute value of single-precision floating-point strided array elements.
|
|
31
|
+
*
|
|
32
|
+
* @param {PositiveInteger} N - number of indexed elements
|
|
33
|
+
* @param {Float32Array} x - input array
|
|
34
|
+
* @param {integer} strideX - `x` stride length
|
|
35
|
+
* @param {NonNegativeInteger} offsetX - starting index for `x`
|
|
36
|
+
* @param {Float32Array} y - output array
|
|
37
|
+
* @param {integer} strideY - `y` stride length
|
|
38
|
+
* @param {NonNegativeInteger} offsetY - starting index for `y`
|
|
39
|
+
* @returns {Float32Array} output array
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
43
|
+
*
|
|
44
|
+
* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
|
|
45
|
+
* var y = new Float32Array( x.length );
|
|
46
|
+
*
|
|
47
|
+
* var v = scuminabs( 4, x, 2, 1, y, 1, 0 );
|
|
48
|
+
* // returns <Float32Array>[ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]
|
|
49
|
+
*/
|
|
50
|
+
function scuminabs( N, x, strideX, offsetX, y, strideY, offsetY ) {
|
|
51
|
+
var min;
|
|
52
|
+
var ix;
|
|
53
|
+
var iy;
|
|
54
|
+
var v;
|
|
55
|
+
var i;
|
|
56
|
+
|
|
57
|
+
if ( N <= 0 ) {
|
|
58
|
+
return y;
|
|
59
|
+
}
|
|
60
|
+
ix = offsetX;
|
|
61
|
+
iy = offsetY;
|
|
62
|
+
|
|
63
|
+
min = absf( x[ ix ] );
|
|
64
|
+
y[ iy ] = min;
|
|
65
|
+
|
|
66
|
+
iy += strideY;
|
|
67
|
+
i = 1;
|
|
68
|
+
if ( isnanf( min ) === false ) {
|
|
69
|
+
for ( i; i < N; i++ ) {
|
|
70
|
+
ix += strideX;
|
|
71
|
+
v = absf( x[ ix ] );
|
|
72
|
+
if ( isnanf( v ) ) {
|
|
73
|
+
min = v;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
if ( v < min ) {
|
|
77
|
+
min = v;
|
|
78
|
+
}
|
|
79
|
+
y[ iy ] = min;
|
|
80
|
+
iy += strideY;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if ( isnanf( min ) ) {
|
|
84
|
+
for ( i; i < N; i++ ) {
|
|
85
|
+
y[ iy ] = min;
|
|
86
|
+
iy += strideY;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return y;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
// EXPORTS //
|
|
94
|
+
|
|
95
|
+
module.exports = scuminabs;
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var addon = require( './../src/addon.node' );
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// MAIN //
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Computes the cumulative minimum absolute value of single-precision floating-point strided array elements.
|
|
30
|
+
*
|
|
31
|
+
* @param {PositiveInteger} N - number of indexed elements
|
|
32
|
+
* @param {Float32Array} x - input array
|
|
33
|
+
* @param {integer} strideX - `x` stride length
|
|
34
|
+
* @param {NonNegativeInteger} offsetX - starting index for `x`
|
|
35
|
+
* @param {Float32Array} y - output array
|
|
36
|
+
* @param {integer} strideY - `y` stride length
|
|
37
|
+
* @param {NonNegativeInteger} offsetY - starting index for `y`
|
|
38
|
+
* @returns {Float32Array} output array
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
42
|
+
*
|
|
43
|
+
* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
|
|
44
|
+
* var y = new Float32Array( x.length );
|
|
45
|
+
*
|
|
46
|
+
* var v = scuminabs( 4, x, 2, 1, y, 1, 0 );
|
|
47
|
+
* // returns <Float32Array>[ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]
|
|
48
|
+
*/
|
|
49
|
+
function scuminabs( N, x, strideX, offsetX, y, strideY, offsetY ) {
|
|
50
|
+
addon.ndarray( N, x, strideX, offsetX, y, strideY, offsetY );
|
|
51
|
+
return y;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
// EXPORTS //
|
|
56
|
+
|
|
57
|
+
module.exports = scuminabs;
|
package/lib/scuminabs.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var stride2offset = require( '@stdlib/strided-base-stride2offset' );
|
|
24
|
+
var ndarray = require( './ndarray.js' );
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// MAIN //
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Computes the cumulative minimum absolute value of single-precision floating-point strided array elements.
|
|
31
|
+
*
|
|
32
|
+
* @param {PositiveInteger} N - number of indexed elements
|
|
33
|
+
* @param {Float32Array} x - input array
|
|
34
|
+
* @param {integer} strideX - `x` stride length
|
|
35
|
+
* @param {Float32Array} y - output array
|
|
36
|
+
* @param {integer} strideY - `y` stride length
|
|
37
|
+
* @returns {Float32Array} output array
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
41
|
+
*
|
|
42
|
+
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
43
|
+
* var y = new Float32Array( x.length );
|
|
44
|
+
*
|
|
45
|
+
* var v = scuminabs( x.length, x, 1, y, 1 );
|
|
46
|
+
* // returns <Float32Array>[ 1.0, 1.0, 1.0 ]
|
|
47
|
+
*/
|
|
48
|
+
function scuminabs( N, x, strideX, y, strideY ) {
|
|
49
|
+
var ox = stride2offset( N, strideX );
|
|
50
|
+
var oy = stride2offset( N, strideY );
|
|
51
|
+
return ndarray( N, x, strideX, ox, y, strideY, oy );
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
// EXPORTS //
|
|
56
|
+
|
|
57
|
+
module.exports = scuminabs;
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var addon = require( './../src/addon.node' );
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// MAIN //
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Computes the cumulative minimum absolute value of single-precision floating-point strided array elements.
|
|
30
|
+
*
|
|
31
|
+
* @param {PositiveInteger} N - number of indexed elements
|
|
32
|
+
* @param {Float32Array} x - input array
|
|
33
|
+
* @param {integer} strideX - `x` stride length
|
|
34
|
+
* @param {Float32Array} y - output array
|
|
35
|
+
* @param {integer} strideY - `y` stride length
|
|
36
|
+
* @returns {Float32Array} output array
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
40
|
+
*
|
|
41
|
+
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
42
|
+
* var y = new Float32Array( x.length );
|
|
43
|
+
*
|
|
44
|
+
* var v = scuminabs( x.length, x, 1, y, 1 );
|
|
45
|
+
* // returns <Float32Array>[ 1.0, 1.0, 1.0 ]
|
|
46
|
+
*/
|
|
47
|
+
function scuminabs( N, x, strideX, y, strideY ) {
|
|
48
|
+
addon( N, x, strideX, y, strideY );
|
|
49
|
+
return y;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
// EXPORTS //
|
|
54
|
+
|
|
55
|
+
module.exports = scuminabs;
|
package/manifest.json
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
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/math-base-assert-is-nanf",
|
|
42
|
+
"@stdlib/math-base-special-absf",
|
|
43
|
+
"@stdlib/blas-base-shared",
|
|
44
|
+
"@stdlib/strided-base-stride2offset",
|
|
45
|
+
"@stdlib/napi-export",
|
|
46
|
+
"@stdlib/napi-argv",
|
|
47
|
+
"@stdlib/napi-argv-int64",
|
|
48
|
+
"@stdlib/napi-argv-strided-float32array"
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"task": "benchmark",
|
|
53
|
+
"wasm": false,
|
|
54
|
+
"src": [
|
|
55
|
+
"./src/main.c"
|
|
56
|
+
],
|
|
57
|
+
"include": [
|
|
58
|
+
"./include"
|
|
59
|
+
],
|
|
60
|
+
"libraries": [],
|
|
61
|
+
"libpath": [],
|
|
62
|
+
"dependencies": [
|
|
63
|
+
"@stdlib/math-base-assert-is-nanf",
|
|
64
|
+
"@stdlib/math-base-special-absf",
|
|
65
|
+
"@stdlib/blas-base-shared",
|
|
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/math-base-assert-is-nanf",
|
|
82
|
+
"@stdlib/math-base-special-absf",
|
|
83
|
+
"@stdlib/blas-base-shared",
|
|
84
|
+
"@stdlib/strided-base-stride2offset"
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"task": "",
|
|
89
|
+
"wasm": true,
|
|
90
|
+
"src": [
|
|
91
|
+
"./src/main.c"
|
|
92
|
+
],
|
|
93
|
+
"include": [
|
|
94
|
+
"./include"
|
|
95
|
+
],
|
|
96
|
+
"libraries": [],
|
|
97
|
+
"libpath": [],
|
|
98
|
+
"dependencies": [
|
|
99
|
+
"@stdlib/math-base-assert-is-nanf",
|
|
100
|
+
"@stdlib/math-base-special-absf",
|
|
101
|
+
"@stdlib/blas-base-shared",
|
|
102
|
+
"@stdlib/strided-base-stride2offset"
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|