Skip to content

Commit e87d921

Browse files
Jai0401kgrytePlaneshifter
authored
refactor: update blas/ext/base/dsort2hp to follow current project conventions
PR-URL: #2302 Closes: #1495 Ref: #1152 --------- Signed-off-by: Philipp Burckhardt <[email protected]> Co-authored-by: Athan Reines <[email protected]> Co-authored-by: Philipp Burckhardt <[email protected]> Reviewed-by: Philipp Burckhardt <[email protected]>
1 parent 51608dc commit e87d921

File tree

6 files changed

+134
-215
lines changed

6 files changed

+134
-215
lines changed

Diff for: lib/node_modules/@stdlib/blas/ext/base/dsort2sh/README.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,11 @@ The `N` and `stride` parameters determine which elements in `x` and `y` are acce
6262

6363
```javascript
6464
var Float64Array = require( '@stdlib/array/float64' );
65-
var floor = require( '@stdlib/math/base/special/floor' );
6665

6766
var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );
6867
var y = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] );
69-
var N = floor( x.length / 2 );
7068

71-
dsort2sh( N, -1.0, x, 2, y, 2 );
69+
dsort2sh( 2, -1.0, x, 2, y, 2 );
7270

7371
console.log( x );
7472
// => <Float64Array>[ 3.0, -2.0, 1.0, -4.0 ]
@@ -81,7 +79,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [
8179

8280
```javascript
8381
var Float64Array = require( '@stdlib/array/float64' );
84-
var floor = require( '@stdlib/math/base/special/floor' );
8582

8683
// Initial arrays...
8784
var x0 = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
@@ -90,10 +87,9 @@ var y0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] );
9087
// Create offset views...
9188
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
9289
var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
93-
var N = floor( x0.length/2 );
9490

9591
// Sort every other element...
96-
dsort2sh( N, -1.0, x1, 2, y1, 2 );
92+
dsort2sh( 2, -1.0, x1, 2, y1, 2 );
9793

9894
console.log( x0 );
9995
// => <Float64Array>[ 1.0, 4.0, 3.0, 2.0 ]

Diff for: lib/node_modules/@stdlib/blas/ext/base/dsort2sh/include.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Source files:
3838
'src_files': [
39-
'<(src_dir)/addon.cpp',
39+
'<(src_dir)/addon.c',
4040
'<!@(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 ] ); }")',
4141
],
4242

Diff for: lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/ndarray.native.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// MODULES //
2222

23-
var Float64Array = require( '@stdlib/array/float64' );
23+
var offsetView = require( '@stdlib/strided/base/offset-view' );
2424
var addon = require( './dsort2sh.native.js' );
2525

2626

@@ -68,8 +68,8 @@ function dsort2sh( N, order, x, strideX, offsetX, y, strideY, offsetY ) {
6868
if ( strideY < 0 ) {
6969
offsetY += (N-1) * strideY;
7070
}
71-
viewX = new Float64Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offsetX), x.length-offsetX ); // eslint-disable-line max-len
72-
viewY = new Float64Array( y.buffer, y.byteOffset+(y.BYTES_PER_ELEMENT*offsetY), y.length-offsetY ); // eslint-disable-line max-len
71+
viewX = offsetView( x, offsetX );
72+
viewY = offsetView( y, offsetY );
7373
addon( N, order, viewX, strideX, viewY, flg*strideY );
7474
return x;
7575
}
+79-41
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,81 @@
11
{
2-
"options": {},
3-
"fields": [
4-
{
5-
"field": "src",
6-
"resolve": true,
7-
"relative": true
8-
},
9-
{
10-
"field": "include",
11-
"resolve": true,
12-
"relative": true
13-
},
14-
{
15-
"field": "libraries",
16-
"resolve": false,
17-
"relative": false
18-
},
19-
{
20-
"field": "libpath",
21-
"resolve": true,
22-
"relative": false
23-
}
24-
],
25-
"confs": [
26-
{
27-
"src": [
28-
"./src/dsort2sh.c"
29-
],
30-
"include": [
31-
"./include"
32-
],
33-
"libraries": [
34-
"-lm"
35-
],
36-
"libpath": [],
37-
"dependencies": [
38-
"@stdlib/math/base/assert/is-nan",
39-
"@stdlib/math/base/assert/is-negative-zero"
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/dsort2sh.c"
32+
],
33+
"include": [
34+
"./include"
35+
],
36+
"libraries": [
37+
"-lm"
38+
],
39+
"libpath": [],
40+
"dependencies": [
41+
"@stdlib/napi/export",
42+
"@stdlib/math/base/assert/is-nan",
43+
"@stdlib/math/base/assert/is-negative-zero",
44+
"@stdlib/napi/argv",
45+
"@stdlib/napi/argv-int64",
46+
"@stdlib/napi/argv-double",
47+
"@stdlib/napi/argv-strided-float64array"
48+
]
49+
},
50+
{
51+
"task": "benchmark",
52+
"src": [
53+
"./src/dsort2sh.c"
54+
],
55+
"include": [
56+
"./include"
57+
],
58+
"libraries": [],
59+
"libpath": [],
60+
"dependencies": [
61+
"@stdlib/math/base/assert/is-nan",
62+
"@stdlib/math/base/assert/is-negative-zero"
63+
]
64+
},
65+
{
66+
"task": "examples",
67+
"src": [
68+
"./src/dsort2sh.c"
69+
],
70+
"include": [
71+
"./include"
72+
],
73+
"libraries": [],
74+
"libpath": [],
75+
"dependencies": [
76+
"@stdlib/math/base/assert/is-nan",
77+
"@stdlib/math/base/assert/is-negative-zero"
78+
]
79+
}
80+
]
4381
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 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/dsort2sh.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_double.h"
24+
#include "stdlib/napi/argv_strided_float64array.h"
25+
#include <node_api.h>
26+
27+
/**
28+
* Receives JavaScript callback invocation data.
29+
*
30+
* @private
31+
* @param env environment under which the function is invoked
32+
* @param info callback data
33+
* @return Node-API value
34+
*/
35+
static napi_value addon( napi_env env, napi_callback_info info ) {
36+
STDLIB_NAPI_ARGV( env, info, argv, argc, 6 );
37+
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
38+
STDLIB_NAPI_ARGV_DOUBLE( env, order, argv, 1 );
39+
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, order, argv, 2 );
40+
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
41+
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, order, argv, 4 );
42+
STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 );
43+
44+
c_dsort2sh( N, order, X, strideX, Y, strideY );
45+
46+
return NULL;
47+
}
48+
49+
STDLIB_NAPI_MODULE_EXPORT_FCN( addon )

0 commit comments

Comments
 (0)