@stdlib/stats-strided-srange 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 +402 -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 +92 -0
- package/include/stdlib/stats/strided/srange.h +45 -0
- package/lib/index.js +68 -0
- package/lib/main.js +35 -0
- package/lib/native.js +35 -0
- package/lib/ndarray.js +83 -0
- package/lib/ndarray.native.js +52 -0
- package/lib/srange.js +52 -0
- package/lib/srange.native.js +51 -0
- package/manifest.json +103 -0
- package/package.json +96 -0
- package/src/addon.c +61 -0
- package/src/main.c +78 -0
|
@@ -0,0 +1,92 @@
|
|
|
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 `srange`.
|
|
23
|
+
*/
|
|
24
|
+
interface Routine {
|
|
25
|
+
/**
|
|
26
|
+
* Computes the range of a single-precision floating-point strided array.
|
|
27
|
+
*
|
|
28
|
+
* @param N - number of indexed elements
|
|
29
|
+
* @param x - input array
|
|
30
|
+
* @param strideX - stride length
|
|
31
|
+
* @returns range
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
35
|
+
*
|
|
36
|
+
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
37
|
+
*
|
|
38
|
+
* var v = srange( x.length, x, 1 );
|
|
39
|
+
* // returns 4.0
|
|
40
|
+
*/
|
|
41
|
+
( N: number, x: Float32Array, strideX: number ): number;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Computes the range of a single-precision floating-point strided array using alternative indexing semantics.
|
|
45
|
+
*
|
|
46
|
+
* @param N - number of indexed elements
|
|
47
|
+
* @param x - input array
|
|
48
|
+
* @param strideX - stride length
|
|
49
|
+
* @param offsetX - starting index
|
|
50
|
+
* @returns range
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
54
|
+
*
|
|
55
|
+
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
56
|
+
*
|
|
57
|
+
* var v = srange.ndarray( x.length, x, 1, 0 );
|
|
58
|
+
* // returns 4.0
|
|
59
|
+
*/
|
|
60
|
+
ndarray( N: number, x: Float32Array, strideX: number, offsetX: number ): number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Computes the range of a single-precision floating-point strided array.
|
|
65
|
+
*
|
|
66
|
+
* @param N - number of indexed elements
|
|
67
|
+
* @param x - input array
|
|
68
|
+
* @param strideX - stride length
|
|
69
|
+
* @returns range
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
73
|
+
*
|
|
74
|
+
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
75
|
+
*
|
|
76
|
+
* var v = srange( x.length, x, 1 );
|
|
77
|
+
* // returns 4.0
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
81
|
+
*
|
|
82
|
+
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
83
|
+
*
|
|
84
|
+
* var v = srange.ndarray( x.length, x, 1, 0 );
|
|
85
|
+
* // returns 4.0
|
|
86
|
+
*/
|
|
87
|
+
declare var srange: Routine;
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
// EXPORTS //
|
|
91
|
+
|
|
92
|
+
export = srange;
|
|
@@ -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_SRANGE_H
|
|
20
|
+
#define STDLIB_STATS_STRIDED_SRANGE_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 range of a single-precision floating-point strided array.
|
|
33
|
+
*/
|
|
34
|
+
float API_SUFFIX(stdlib_strided_srange)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Computes the range of a single-precision floating-point strided array using alternative indexing semantics.
|
|
38
|
+
*/
|
|
39
|
+
float API_SUFFIX(stdlib_strided_srange_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
|
|
40
|
+
|
|
41
|
+
#ifdef __cplusplus
|
|
42
|
+
}
|
|
43
|
+
#endif
|
|
44
|
+
|
|
45
|
+
#endif // !STDLIB_STATS_STRIDED_SRANGE_H
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
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 range of a single-precision floating-point strided array.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/stats-strided-srange
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
28
|
+
* var srange = require( '@stdlib/stats-strided-srange' );
|
|
29
|
+
*
|
|
30
|
+
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
31
|
+
*
|
|
32
|
+
* var v = srange( x.length, x, 1 );
|
|
33
|
+
* // returns 4.0
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
37
|
+
* var srange = require( '@stdlib/stats-strided-srange' );
|
|
38
|
+
*
|
|
39
|
+
* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
|
|
40
|
+
*
|
|
41
|
+
* var v = srange.ndarray( 4, x, 2, 1 );
|
|
42
|
+
* // returns 6.0
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
// MODULES //
|
|
46
|
+
|
|
47
|
+
var join = require( 'path' ).join;
|
|
48
|
+
var tryRequire = require( '@stdlib/utils-try-require' );
|
|
49
|
+
var isError = require( '@stdlib/assert-is-error' );
|
|
50
|
+
var main = require( './main.js' );
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
// MAIN //
|
|
54
|
+
|
|
55
|
+
var srange;
|
|
56
|
+
var tmp = tryRequire( join( __dirname, './native.js' ) );
|
|
57
|
+
if ( isError( tmp ) ) {
|
|
58
|
+
srange = main;
|
|
59
|
+
} else {
|
|
60
|
+
srange = tmp;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
// EXPORTS //
|
|
65
|
+
|
|
66
|
+
module.exports = srange;
|
|
67
|
+
|
|
68
|
+
// exports: { "ndarray": "srange.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 srange = require( './srange.js' );
|
|
25
|
+
var ndarray = require( './ndarray.js' );
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
// MAIN //
|
|
29
|
+
|
|
30
|
+
setReadOnly( srange, 'ndarray', ndarray );
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// EXPORTS //
|
|
34
|
+
|
|
35
|
+
module.exports = srange;
|
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 srange = require( './srange.native.js' );
|
|
25
|
+
var ndarray = require( './ndarray.native.js' );
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
// MAIN //
|
|
29
|
+
|
|
30
|
+
setReadOnly( srange, 'ndarray', ndarray );
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
// EXPORTS //
|
|
34
|
+
|
|
35
|
+
module.exports = srange;
|
package/lib/ndarray.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
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 float64ToFloat32 = require( '@stdlib/number-float64-base-to-float32' );
|
|
24
|
+
var isnanf = require( '@stdlib/math-base-assert-is-nanf' );
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// MAIN //
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Computes the range of a single-precision floating-point strided array.
|
|
31
|
+
*
|
|
32
|
+
* @param {PositiveInteger} N - number of indexed elements
|
|
33
|
+
* @param {Float32Array} x - input array
|
|
34
|
+
* @param {integer} strideX - stride length
|
|
35
|
+
* @param {NonNegativeInteger} offsetX - starting index
|
|
36
|
+
* @returns {number} range
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
40
|
+
*
|
|
41
|
+
* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
|
|
42
|
+
*
|
|
43
|
+
* var v = srange( 4, x, 2, 1 );
|
|
44
|
+
* // returns 6.0
|
|
45
|
+
*/
|
|
46
|
+
function srange( N, x, strideX, offsetX ) {
|
|
47
|
+
var max;
|
|
48
|
+
var min;
|
|
49
|
+
var ix;
|
|
50
|
+
var v;
|
|
51
|
+
var i;
|
|
52
|
+
|
|
53
|
+
if ( N <= 0 ) {
|
|
54
|
+
return NaN;
|
|
55
|
+
}
|
|
56
|
+
if ( N === 1 || strideX === 0 ) {
|
|
57
|
+
if ( isnanf( x[ offsetX ] ) ) {
|
|
58
|
+
return NaN;
|
|
59
|
+
}
|
|
60
|
+
return 0.0;
|
|
61
|
+
}
|
|
62
|
+
ix = offsetX;
|
|
63
|
+
min = x[ ix ];
|
|
64
|
+
max = min;
|
|
65
|
+
for ( i = 1; i < N; i++ ) {
|
|
66
|
+
ix += strideX;
|
|
67
|
+
v = x[ ix ];
|
|
68
|
+
if ( isnanf( v ) ) {
|
|
69
|
+
return v;
|
|
70
|
+
}
|
|
71
|
+
if ( v < min ) {
|
|
72
|
+
min = v;
|
|
73
|
+
} else if ( v > max ) {
|
|
74
|
+
max = v;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return float64ToFloat32( max - min );
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
// EXPORTS //
|
|
82
|
+
|
|
83
|
+
module.exports = srange;
|
|
@@ -0,0 +1,52 @@
|
|
|
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 range of a single-precision floating-point strided array.
|
|
30
|
+
*
|
|
31
|
+
* @param {PositiveInteger} N - number of indexed elements
|
|
32
|
+
* @param {Float32Array} x - input array
|
|
33
|
+
* @param {integer} strideX - stride length
|
|
34
|
+
* @param {NonNegativeInteger} offsetX - starting index
|
|
35
|
+
* @returns {number} range
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
39
|
+
*
|
|
40
|
+
* var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
|
|
41
|
+
*
|
|
42
|
+
* var v = srange( 4, x, 2, 1 );
|
|
43
|
+
* // returns 6.0
|
|
44
|
+
*/
|
|
45
|
+
function srange( N, x, strideX, offsetX ) {
|
|
46
|
+
return addon.ndarray( N, x, strideX, offsetX );
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
// EXPORTS //
|
|
51
|
+
|
|
52
|
+
module.exports = srange;
|
package/lib/srange.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
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 range of a single-precision floating-point strided array.
|
|
31
|
+
*
|
|
32
|
+
* @param {PositiveInteger} N - number of indexed elements
|
|
33
|
+
* @param {Float32Array} x - input array
|
|
34
|
+
* @param {integer} strideX - stride length
|
|
35
|
+
* @returns {number} range
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
39
|
+
*
|
|
40
|
+
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
41
|
+
*
|
|
42
|
+
* var v = srange( x.length, x, 1 );
|
|
43
|
+
* // returns 4.0
|
|
44
|
+
*/
|
|
45
|
+
function srange( N, x, strideX ) {
|
|
46
|
+
return ndarray( N, x, strideX, stride2offset( N, strideX ) );
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
// EXPORTS //
|
|
51
|
+
|
|
52
|
+
module.exports = srange;
|
|
@@ -0,0 +1,51 @@
|
|
|
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 range of a single-precision floating-point strided array.
|
|
30
|
+
*
|
|
31
|
+
* @param {PositiveInteger} N - number of indexed elements
|
|
32
|
+
* @param {Float32Array} x - input array
|
|
33
|
+
* @param {integer} strideX - stride length
|
|
34
|
+
* @returns {number} range
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
38
|
+
*
|
|
39
|
+
* var x = new Float32Array( [ 1.0, -2.0, 2.0 ] );
|
|
40
|
+
*
|
|
41
|
+
* var v = srange( x.length, x, 1 );
|
|
42
|
+
* // returns 4.0
|
|
43
|
+
*/
|
|
44
|
+
function srange( N, x, strideX ) {
|
|
45
|
+
return addon( N, x, strideX );
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// EXPORTS //
|
|
50
|
+
|
|
51
|
+
module.exports = srange;
|
package/manifest.json
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
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/strided-base-stride2offset",
|
|
43
|
+
"@stdlib/math-base-assert-is-nanf",
|
|
44
|
+
"@stdlib/napi-export",
|
|
45
|
+
"@stdlib/napi-argv",
|
|
46
|
+
"@stdlib/napi-argv-int64",
|
|
47
|
+
"@stdlib/napi-argv-strided-float32array",
|
|
48
|
+
"@stdlib/napi-create-double"
|
|
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/blas-base-shared",
|
|
64
|
+
"@stdlib/strided-base-stride2offset",
|
|
65
|
+
"@stdlib/math-base-assert-is-nanf"
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"task": "examples",
|
|
70
|
+
"wasm": false,
|
|
71
|
+
"src": [
|
|
72
|
+
"./src/main.c"
|
|
73
|
+
],
|
|
74
|
+
"include": [
|
|
75
|
+
"./include"
|
|
76
|
+
],
|
|
77
|
+
"libraries": [],
|
|
78
|
+
"libpath": [],
|
|
79
|
+
"dependencies": [
|
|
80
|
+
"@stdlib/blas-base-shared",
|
|
81
|
+
"@stdlib/strided-base-stride2offset",
|
|
82
|
+
"@stdlib/math-base-assert-is-nanf"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"task": "",
|
|
87
|
+
"wasm": true,
|
|
88
|
+
"src": [
|
|
89
|
+
"./src/main.c"
|
|
90
|
+
],
|
|
91
|
+
"include": [
|
|
92
|
+
"./include"
|
|
93
|
+
],
|
|
94
|
+
"libraries": [],
|
|
95
|
+
"libpath": [],
|
|
96
|
+
"dependencies": [
|
|
97
|
+
"@stdlib/blas-base-shared",
|
|
98
|
+
"@stdlib/strided-base-stride2offset",
|
|
99
|
+
"@stdlib/math-base-assert-is-nanf"
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
}
|