Skip to content

Commit

Permalink
refactor: update blas/ext/base/ssortsh to follow current project co…
Browse files Browse the repository at this point in the history
…nventions

PR-URL: #1905
Closes: #1539
Ref: #1152

---------

Co-authored-by: Philipp Burckhardt <[email protected]>
Reviewed-by: Philipp Burckhardt <[email protected]>
  • Loading branch information
Sivam2313 and Planeshifter authored Apr 28, 2024
1 parent 657f3c3 commit 2ca4ab3
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 179 deletions.
10 changes: 4 additions & 6 deletions lib/node_modules/@stdlib/blas/ext/base/ssortsh/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,18 @@

// Using `N` and `stride` parameters:
> x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, -4.0 ] );
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
> {{alias}}( N, -1, x, 2 )
> {{alias}}( 2, -1, x, 2 )
<Float32Array>[ 3.0, -2.0, 1.0, -4.0 ]

// Using view offsets:
> var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, -4.0 ] );
> var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
> N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
> {{alias}}( N, 1, x1, 2 )
> {{alias}}( 2, 1, x1, 2 )
<Float32Array>[ -4.0, 3.0, -2.0 ]
> x0
<Float32Array>[ 1.0, -4.0, 3.0, -2.0 ]


{{alias}}.ndarray( N, order, x, stride, offset )
Sorts a single-precision floating-point strided array using Shellsort and
alternative indexing semantics.
Expand Down Expand Up @@ -112,8 +111,7 @@

// Using an index offset:
> x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, -4.0 ] );
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
> {{alias}}.ndarray( N, 1, x, 2, 1 )
> {{alias}}.ndarray( 2, 1, x, 2, 1 )
<Float32Array>[ 1.0, -4.0, 3.0, -2.0 ]

See Also
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

// MODULES //

var Float32Array = require( '@stdlib/array/float32' );
var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' );
var offsetView = require( '@stdlib/strided/base/offset-view' );
var addon = require( './ssortsh.native.js' );


Expand All @@ -45,12 +46,12 @@ var addon = require( './ssortsh.native.js' );
*/
function ssortsh( N, order, x, stride, offset ) {
var view;
offset = minViewBufferIndex( N, stride, offset );
if ( stride < 0 ) {
order *= -1.0;
stride *= -1;
offset -= (N-1) * stride;
}
view = new Float32Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), x.length-offset ); // eslint-disable-line max-len
view = offsetView( x, offset );
addon( N, order, view, stride );
return x;
}
Expand Down
87 changes: 46 additions & 41 deletions lib/node_modules/@stdlib/blas/ext/base/ssortsh/manifest.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
{
"options": {},
"fields": [
{
"field": "src",
"resolve": true,
"relative": true
},
{
"field": "include",
"resolve": true,
"relative": true
},
{
"field": "libraries",
"resolve": false,
"relative": false
},
{
"field": "libpath",
"resolve": true,
"relative": false
}
],
"confs": [
{
"src": [
"./src/ssortsh.c"
],
"include": [
"./include"
],
"libraries": [
"-lm"
],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nanf",
"@stdlib/math/base/assert/is-negative-zerof"
]
}
]
"options": {},
"fields": [
{
"field": "src",
"resolve": true,
"relative": true
},
{
"field": "include",
"resolve": true,
"relative": true
},
{
"field": "libraries",
"resolve": false,
"relative": false
},
{
"field": "libpath",
"resolve": true,
"relative": false
}
],
"confs": [
{
"src": [
"./src/ssortsh.c"
],
"include": [
"./include"
],
"libraries": [
"-lm"
],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nanf",
"@stdlib/math/base/assert/is-negative-zerof",
"@stdlib/napi/export",
"@stdlib/napi/argv",
"@stdlib/napi/argv-float",
"@stdlib/napi/argv-int64",
"@stdlib/napi/argv-strided-float32array"
]
}
]
}
37 changes: 37 additions & 0 deletions lib/node_modules/@stdlib/blas/ext/base/ssortsh/src/addon.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2020 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "stdlib/blas/ext/base/ssortsh.h"
#include "stdlib/napi/export.h"
#include "stdlib/napi/argv.h"
#include "stdlib/napi/argv_float.h"
#include "stdlib/napi/argv_int64.h"
#include "stdlib/napi/argv_strided_float32array.h"
#include <node_api.h>

static napi_value addon( napi_env env, napi_callback_info info ) {
STDLIB_NAPI_ARGV( env, info, argv, argc, 4 );
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
STDLIB_NAPI_ARGV_FLOAT( env, order, argv, 1 );
STDLIB_NAPI_ARGV_INT64( env, stride, argv, 3 );
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, stride, argv, 2 );
c_ssortsh( N, order, X, stride );
return NULL;
}

STDLIB_NAPI_MODULE_EXPORT_FCN( addon )
128 changes: 0 additions & 128 deletions lib/node_modules/@stdlib/blas/ext/base/ssortsh/src/addon.cpp

This file was deleted.

1 comment on commit 2ca4ab3

@stdlib-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage Report

Package Statements Branches Functions Lines
blas/ext/base/ssortsh $\color{green}469/469$
$\color{green}+100.00\%$
$\color{green}49/49$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}469/469$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this push.

Please sign in to comment.