@stdlib/blas-ext-base-dsorthp 0.2.0 → 0.2.2
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/README.md +4 -8
- package/lib/ndarray.native.js +5 -3
- package/manifest.json +49 -41
- package/package.json +16 -34
- package/src/addon.c +44 -0
- package/include.gypi +0 -53
- package/src/addon.cpp +0 -128
package/README.md
CHANGED
|
@@ -77,12 +77,10 @@ The `N` and `stride` parameters determine which elements in `x` are accessed at
|
|
|
77
77
|
|
|
78
78
|
```javascript
|
|
79
79
|
var Float64Array = require( '@stdlib/array-float64' );
|
|
80
|
-
var floor = require( '@stdlib/math-base-special-floor' );
|
|
81
80
|
|
|
82
81
|
var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );
|
|
83
|
-
var N = floor( x.length / 2 );
|
|
84
82
|
|
|
85
|
-
dsorthp(
|
|
83
|
+
dsorthp( 2, -1.0, x, 2 );
|
|
86
84
|
// x => <Float64Array>[ 3.0, -2.0, 1.0, -4.0 ]
|
|
87
85
|
```
|
|
88
86
|
|
|
@@ -90,17 +88,15 @@ Note that indexing is relative to the first index. To introduce an offset, use [
|
|
|
90
88
|
|
|
91
89
|
```javascript
|
|
92
90
|
var Float64Array = require( '@stdlib/array-float64' );
|
|
93
|
-
var floor = require( '@stdlib/math-base-special-floor' );
|
|
94
91
|
|
|
95
92
|
// Initial array...
|
|
96
93
|
var x0 = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
|
|
97
94
|
|
|
98
95
|
// Create an offset view...
|
|
99
96
|
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
|
|
100
|
-
var N = floor( x0.length/2 );
|
|
101
97
|
|
|
102
98
|
// Sort every other element...
|
|
103
|
-
dsorthp(
|
|
99
|
+
dsorthp( 2, -1.0, x1, 2 );
|
|
104
100
|
// x0 => <Float64Array>[ 1.0, 4.0, 3.0, 2.0 ]
|
|
105
101
|
```
|
|
106
102
|
|
|
@@ -257,8 +253,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
257
253
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/blas-ext-base-dsorthp.svg
|
|
258
254
|
[npm-url]: https://npmjs.org/package/@stdlib/blas-ext-base-dsorthp
|
|
259
255
|
|
|
260
|
-
[test-image]: https://github.com/stdlib-js/blas-ext-base-dsorthp/actions/workflows/test.yml/badge.svg?branch=v0.2.
|
|
261
|
-
[test-url]: https://github.com/stdlib-js/blas-ext-base-dsorthp/actions/workflows/test.yml?query=branch:v0.2.
|
|
256
|
+
[test-image]: https://github.com/stdlib-js/blas-ext-base-dsorthp/actions/workflows/test.yml/badge.svg?branch=v0.2.2
|
|
257
|
+
[test-url]: https://github.com/stdlib-js/blas-ext-base-dsorthp/actions/workflows/test.yml?query=branch:v0.2.2
|
|
262
258
|
|
|
263
259
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-dsorthp/main.svg
|
|
264
260
|
[coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-dsorthp?branch=main
|
package/lib/ndarray.native.js
CHANGED
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
|
-
var
|
|
23
|
+
var minViewBufferIndex = require( '@stdlib/strided-base-min-view-buffer-index' );
|
|
24
|
+
var offsetView = require( '@stdlib/strided-base-offset-view' );
|
|
24
25
|
var addon = require( './dsorthp.native.js' );
|
|
25
26
|
|
|
26
27
|
|
|
@@ -45,12 +46,13 @@ var addon = require( './dsorthp.native.js' );
|
|
|
45
46
|
*/
|
|
46
47
|
function dsorthp( N, order, x, stride, offset ) {
|
|
47
48
|
var view;
|
|
49
|
+
offset = minViewBufferIndex( N, stride, offset );
|
|
48
50
|
if ( stride < 0 ) {
|
|
49
51
|
order *= -1.0;
|
|
50
52
|
stride *= -1;
|
|
51
|
-
offset -= (N-1) * stride;
|
|
52
53
|
}
|
|
53
|
-
view =
|
|
54
|
+
view = offsetView( x, offset );
|
|
55
|
+
|
|
54
56
|
addon( N, order, view, stride );
|
|
55
57
|
return x;
|
|
56
58
|
}
|
package/manifest.json
CHANGED
|
@@ -1,43 +1,51 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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/dsorthp.c"
|
|
32
|
+
],
|
|
33
|
+
"include": [
|
|
34
|
+
"./include"
|
|
35
|
+
],
|
|
36
|
+
"libraries": [
|
|
37
|
+
"-lm"
|
|
38
|
+
],
|
|
39
|
+
"libpath": [],
|
|
40
|
+
"dependencies": [
|
|
41
|
+
"@stdlib/math-base-assert-is-nan",
|
|
42
|
+
"@stdlib/math-base-assert-is-positive-zero",
|
|
43
|
+
"@stdlib/napi-export",
|
|
44
|
+
"@stdlib/napi-argv",
|
|
45
|
+
"@stdlib/napi-argv-double",
|
|
46
|
+
"@stdlib/napi-argv-int64",
|
|
47
|
+
"@stdlib/napi-argv-strided-float64array"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
]
|
|
43
51
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/blas-ext-base-dsorthp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Sort a double-precision floating-point strided array using heapsort.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -17,21 +17,14 @@
|
|
|
17
17
|
"browser": "./lib/main.js",
|
|
18
18
|
"gypfile": false,
|
|
19
19
|
"directories": {
|
|
20
|
-
"benchmark": "./benchmark",
|
|
21
20
|
"doc": "./docs",
|
|
22
|
-
"example": "./examples",
|
|
23
21
|
"include": "./include",
|
|
24
22
|
"lib": "./lib",
|
|
25
23
|
"src": "./src",
|
|
26
|
-
"
|
|
24
|
+
"dist": "./dist"
|
|
27
25
|
},
|
|
28
26
|
"types": "./docs/types",
|
|
29
|
-
"scripts": {
|
|
30
|
-
"test": "make test",
|
|
31
|
-
"test-cov": "make test-cov",
|
|
32
|
-
"examples": "make examples",
|
|
33
|
-
"benchmark": "make benchmark"
|
|
34
|
-
},
|
|
27
|
+
"scripts": {},
|
|
35
28
|
"homepage": "https://stdlib.io",
|
|
36
29
|
"repository": {
|
|
37
30
|
"type": "git",
|
|
@@ -41,31 +34,20 @@
|
|
|
41
34
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
42
35
|
},
|
|
43
36
|
"dependencies": {
|
|
44
|
-
"@stdlib/assert-is-error": "^0.2.
|
|
45
|
-
"@stdlib/math-base-assert-is-nan": "^0.2.
|
|
46
|
-
"@stdlib/math-base-assert-is-positive-zero": "^0.2.
|
|
47
|
-
"@stdlib/math-base-special-floor": "^0.2.
|
|
48
|
-
"@stdlib/
|
|
49
|
-
"@stdlib/
|
|
50
|
-
"@stdlib/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"@stdlib/
|
|
54
|
-
"@stdlib/
|
|
55
|
-
"@stdlib/
|
|
56
|
-
"@stdlib/math-base-assert-is-negative-zero": "^0.1.1",
|
|
57
|
-
"@stdlib/math-base-special-pow": "^0.1.0",
|
|
58
|
-
"@stdlib/math-base-special-round": "^0.1.1",
|
|
59
|
-
"@stdlib/random-base-discrete-uniform": "^0.1.0",
|
|
60
|
-
"@stdlib/random-base-randu": "^0.1.0",
|
|
61
|
-
"@stdlib/random-base-uniform": "^0.1.0",
|
|
62
|
-
"proxyquire": "^2.0.0",
|
|
63
|
-
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
64
|
-
"istanbul": "^0.4.1",
|
|
65
|
-
"tap-min": "git+https://github.com/Planeshifter/tap-min.git",
|
|
66
|
-
"@stdlib/bench-harness": "^0.2.0",
|
|
67
|
-
"@stdlib/bench": "^0.3.1"
|
|
37
|
+
"@stdlib/assert-is-error": "^0.2.2",
|
|
38
|
+
"@stdlib/math-base-assert-is-nan": "^0.2.2",
|
|
39
|
+
"@stdlib/math-base-assert-is-positive-zero": "^0.2.2",
|
|
40
|
+
"@stdlib/math-base-special-floor": "^0.2.3",
|
|
41
|
+
"@stdlib/napi-argv": "^0.2.2",
|
|
42
|
+
"@stdlib/napi-argv-double": "^0.2.1",
|
|
43
|
+
"@stdlib/napi-argv-int64": "^0.2.2",
|
|
44
|
+
"@stdlib/napi-argv-strided-float64array": "^0.2.2",
|
|
45
|
+
"@stdlib/napi-export": "^0.2.2",
|
|
46
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
|
|
47
|
+
"@stdlib/utils-library-manifest": "^0.2.2",
|
|
48
|
+
"@stdlib/utils-try-require": "^0.2.2"
|
|
68
49
|
},
|
|
50
|
+
"devDependencies": {},
|
|
69
51
|
"engines": {
|
|
70
52
|
"node": ">=0.10.0",
|
|
71
53
|
"npm": ">2.7.0"
|
package/src/addon.c
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
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/blas/ext/base/dsorthp.h"
|
|
20
|
+
#include "stdlib/napi/export.h"
|
|
21
|
+
#include "stdlib/napi/argv.h"
|
|
22
|
+
#include "stdlib/napi/argv_double.h"
|
|
23
|
+
#include "stdlib/napi/argv_int64.h"
|
|
24
|
+
#include "stdlib/napi/argv_strided_float64array.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, 4 );
|
|
36
|
+
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
|
|
37
|
+
STDLIB_NAPI_ARGV_DOUBLE( env, order, argv, 1 );
|
|
38
|
+
STDLIB_NAPI_ARGV_INT64( env, stride, argv, 3 );
|
|
39
|
+
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, stride, argv, 2 );
|
|
40
|
+
c_dsorthp( N, order, X, stride );
|
|
41
|
+
return NULL;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
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,128 +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/blas/ext/base/dsorthp.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_blas_ext_base_dsorthp {
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Sorts a double-precision floating-point strided array using heapsort.
|
|
33
|
-
*
|
|
34
|
-
* ## Notes
|
|
35
|
-
*
|
|
36
|
-
* - When called from JavaScript, the function expects four arguments:
|
|
37
|
-
*
|
|
38
|
-
* - `N`: number of indexed elements
|
|
39
|
-
* - `order`: sort order
|
|
40
|
-
* - `X`: input array
|
|
41
|
-
* - `strideX`: `X` stride length
|
|
42
|
-
*/
|
|
43
|
-
napi_value node_dsorthp( 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 res2;
|
|
73
|
-
status = napi_is_typedarray( env, argv[ 2 ], &res2 );
|
|
74
|
-
assert( status == napi_ok );
|
|
75
|
-
if ( res2 == false ) {
|
|
76
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float64Array." );
|
|
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 order;
|
|
93
|
-
status = napi_get_value_double( env, argv[ 1 ], &order );
|
|
94
|
-
assert( status == napi_ok );
|
|
95
|
-
|
|
96
|
-
int64_t strideX;
|
|
97
|
-
status = napi_get_value_int64( env, argv[ 3 ], &strideX );
|
|
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_float64_array ) {
|
|
106
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float64Array." );
|
|
107
|
-
return nullptr;
|
|
108
|
-
}
|
|
109
|
-
if ( (N-1)*llabs(strideX) >= (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
|
-
c_dsorthp( N, order, (double *)X, strideX );
|
|
115
|
-
|
|
116
|
-
return nullptr;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
napi_value Init( napi_env env, napi_value exports ) {
|
|
120
|
-
napi_status status;
|
|
121
|
-
napi_value fcn;
|
|
122
|
-
status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_dsorthp, NULL, &fcn );
|
|
123
|
-
assert( status == napi_ok );
|
|
124
|
-
return fcn;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
NAPI_MODULE( NODE_GYP_MODULE_NAME, Init )
|
|
128
|
-
} // end namespace stdlib_blas_ext_base_dsorthp
|