Skip to content

refactor: update blas/ext/ssort2ins to follow current project conventions #1874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9043051
refactor: update to follow current project conventions
vr-varad Mar 13, 2024
92d9013
refactor: update blas/ext/base/ssort2ins to follow current project co…
vr-varad Mar 13, 2024
abc3316
refactor: update blas/ext/base/ssort2ins to follow current project co…
vr-varad Mar 13, 2024
4a3d8c9
refactor: update blas/ext/base/ssort2ins to follow current project co…
vr-varad Mar 13, 2024
f74eedd
refactor: update blas/ext/base/ssort2ins to follow current project co…
vr-varad Mar 13, 2024
0db2bf0
refactor: update blas/ext/base/ssort2ins to follow current project co…
vr-varad Mar 13, 2024
3b66462
refactor: update blas/ext/base/ssort2ins to follow current project co…
vr-varad Mar 13, 2024
da6595c
refactor: update blas/ext/base/ssort2ins to follow current project co…
vr-varad Mar 13, 2024
a3b8e2f
refactor: update blas/ext/base/ssort2ins to follow current project co…
vr-varad Mar 13, 2024
a2dbfd6
refactor: update blas/ext/base/ssort2ins to follow current project co…
vr-varad Mar 13, 2024
7d6fd89
refactor: update blas/ext/base/ssort2ins to follow current project co…
vr-varad Mar 14, 2024
4421608
refactor: update blas/ext/base/ssort2ins to follow current project co…
vr-varad Mar 14, 2024
85365a8
refactor: update blas/ext/base/ssort2ins to follow current project co…
vr-varad Mar 14, 2024
5f00ef5
refactor: update blas/ext/base/ssort2ins to follow current project co…
vr-varad Mar 14, 2024
a9a4836
refactor: update blas/ext/base/ssort2ins to follow current project co…
vr-varad Mar 14, 2024
4f7514a
refactor: update blas/ext/base/ssort2ins to follow current project co…
vr-varad Mar 14, 2024
86ec106
Merge branch 'stdlib-js:develop' into feat/ssort2ins
vr-varad Mar 21, 2024
2f494e0
Merge branch 'stdlib-js:develop' into feat/ssort2ins
vr-varad Mar 24, 2024
504306f
fix: resolved issues
vr-varad Mar 24, 2024
0362d8a
fix: resolved issues
vr-varad Mar 24, 2024
fc5c908
fix: resolved issues
vr-varad Mar 24, 2024
945ea98
fix: made changes in manifest.json
vr-varad Mar 24, 2024
feac823
fix: made changes in manifest.json
vr-varad Mar 24, 2024
bfbbcfb
fix: made changes in manifest.json
vr-varad Mar 24, 2024
d60a85f
fix: made changes in manifest.json
vr-varad Mar 24, 2024
3892a6b
fix: made changes
vr-varad Mar 24, 2024
61e9c6f
fix: made changes
vr-varad Mar 24, 2024
73ddada
Merge branch 'stdlib-js:develop' into feat/ssort2ins
vr-varad Mar 30, 2024
f3e07d2
fix: fixed some issues in ndarray.native.js
vr-varad Mar 30, 2024
8821185
fix: fixed some issues in ndarray.native.js
vr-varad Mar 30, 2024
95aa3db
fix: fixed some issues in ndarray.native.js
vr-varad Mar 30, 2024
1c99356
fix: fixed some issues in ndarray.native.js
vr-varad Mar 30, 2024
f178d03
fix: fixed some issues in ndarray.native.js
vr-varad Mar 30, 2024
741c938
fix: fixed some issues in ndarray.native.js
vr-varad Mar 30, 2024
79a40af
fix: fixed some issues in ndarray.native.js
vr-varad Mar 30, 2024
0b58f32
chore: remove unneeded casts
Planeshifter Apr 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions lib/node_modules/@stdlib/blas/ext/base/ssort2ins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,14 @@ The function has the following parameters:
- **y**: second input [`Float32Array`][@stdlib/array/float32].
- **strideY**: `y` index increment.

The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to sort every other element
The `N` and `stride` parameters determine which elements in the strided arrays are accessed at runtime. For example, to sort every other element

```javascript
var Float32Array = require( '@stdlib/array/float32' );
var floor = require( '@stdlib/math/base/special/floor' );

var x = new Float32Array( [ 1.0, -2.0, 3.0, -4.0 ] );
var y = new Float32Array( [ 0.0, 1.0, 2.0, 3.0 ] );
var N = floor( x.length / 2 );

ssort2ins( N, -1.0, x, 2, y, 2 );
ssort2ins( 2, -1.0, x, 2, y, 2 );

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

```javascript
var Float32Array = require( '@stdlib/array/float32' );
var floor = require( '@stdlib/math/base/special/floor' );

// Initial arrays...
var x0 = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] );
Expand All @@ -90,10 +86,9 @@ var y0 = new Float32Array( [ 0.0, 1.0, 2.0, 3.0 ] );
// Create offset views...
var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var N = floor( x0.length/2 );

// Sort every other element...
ssort2ins( N, -1.0, x1, 2, y1, 2 );
ssort2ins( 2, -1.0, x1, 2, y1, 2 );

console.log( x0 );
// => <Float32Array>[ 1.0, 4.0, 3.0, 2.0 ]
Expand All @@ -104,7 +99,7 @@ console.log( y0 );

#### ssort2ins.ndarray( N, order, x, strideX, offsetX, y, strideY, offsetY )

Simultaneously sorts two single-precision floating-point strided arrays based on the sort order of the first array `x` using insertion sort and alternative indexing semantics.
Simultaneously sorts two single-precision floating-point strided arrays based on the sort order of the first array the strided array using insertion sort and alternative indexing semantics.

```javascript
var Float32Array = require( '@stdlib/array/float32' );
Expand All @@ -126,7 +121,7 @@ The function has the following additional parameters:
- **offsetX**: `x` starting index.
- **offsetY**: `y` starting index.

While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x`
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x`.

```javascript
var Float32Array = require( '@stdlib/array/float32' );
Expand Down
25 changes: 12 additions & 13 deletions lib/node_modules/@stdlib/blas/ext/base/ssort2ins/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
Simultaneously sorts two single-precision floating-point strided arrays
based on the sort order of the first array using insertion sort.

The `N` and `stride` parameters determine which elements in `x` and `y` are
accessed at runtime.
The `N` and stride parameters determine which elements in the strided
arrays are accessed at runtime.

Indexing is relative to the first index. To introduce an offset, use typed
array views.

If `N <= 0` or `order == 0`, the function leaves `x` and `y` unchanged.
If `N <= 0` or `order == 0`, the function leaves the strided arrays
are unchanged.

The algorithm distinguishes between `-0` and `+0`. When sorted in increasing
order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is
Expand Down Expand Up @@ -57,7 +58,7 @@
Returns
-------
x: Float32Array
Input array `x`.
First input array.

Examples
--------
Expand All @@ -69,11 +70,10 @@
> y
<Float32Array>[ 3.0, 1.0, 0.0, 2.0 ]

// Using `N` and `stride` parameters:
// Using `N` and stride parameters:
> x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, -4.0 ] );
> y = new {{alias:@stdlib/array/float32}}( [ 0.0, 1.0, 2.0, 3.0 ] );
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
> {{alias}}( N, -1, x, 2, y, 2 )
> {{alias}}( 2, -1, x, 2, y, 2 )
<Float32Array>[ 3.0, -2.0, 1.0, -4.0 ]
> y
<Float32Array>[ 2.0, 1.0, 0.0, 3.0 ]
Expand All @@ -83,21 +83,21 @@
> var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
> var y0 = new {{alias:@stdlib/array/float32}}( [ 0.0, 1.0, 2.0, 3.0 ] );
> var y1 = new {{alias:@stdlib/array/float32}}( y0.buffer, y0.BYTES_PER_ELEMENT*1 );
> N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
> {{alias}}( N, 1, x1, 2, y1, 2 )
> {{alias}}( 2, 1, x1, 2, y1, 2 )
<Float32Array>[ -4.0, 3.0, -2.0 ]
> x0
<Float32Array>[ 1.0, -4.0, 3.0, -2.0 ]
> y0
<Float32Array>[ 0.0, 3.0, 2.0, 1.0 ]


{{alias}}.ndarray( N, order, x, strideX, offsetX, y, strideY, offsetY )
Simultaneously sorts two single-precision floating-point strided arrays
based on the sort order of the first array using insertion sort and
alternative indexing semantics.

While typed array views mandate a view offset based on the underlying
buffer, the `offset` parameter supports indexing semantics based on a
buffer, the offset parameter supports indexing semantics based on a
starting index.

Parameters
Expand Down Expand Up @@ -130,7 +130,7 @@
Returns
-------
x: Float32Array
Input array `x`.
First input array.

Examples
--------
Expand All @@ -145,8 +145,7 @@
// Using an index offset:
> x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, -4.0 ] );
> y = new {{alias:@stdlib/array/float32}}( [ 0.0, 1.0, 2.0, 3.0 ] );
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
> {{alias}}.ndarray( N, 1, x, 2, 1, y, 2, 1 )
> {{alias}}.ndarray( 2, 1, x, 2, 1, y, 2, 1 )
<Float32Array>[ 1.0, -4.0, 3.0, -2.0 ]
> y
<Float32Array>[ 0.0, 3.0, 2.0, 1.0 ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface Routine {
* @param strideX - `x` stride length
* @param y - second input array
* @param strideY - `y` stride length
* @returns `x`
* @returns first input array
*
* @example
* var Float32Array = require( '@stdlib/array/float32' );
Expand Down Expand Up @@ -60,7 +60,7 @@ interface Routine {
* @param y - second input array
* @param strideY - `y` stride length
* @param offsetY - `y` starting index
* @returns `x`
* @returns first input array
*
* @example
* var Float32Array = require( '@stdlib/array/float32' );
Expand Down Expand Up @@ -88,7 +88,7 @@ interface Routine {
* @param strideX - `x` stride length
* @param y - second input array
* @param strideY - `y` stride length
* @returns `x`
* @returns first input array
*
* @example
* var Float32Array = require( '@stdlib/array/float32' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ int main( void ) {
printf( "y[ %i ] = %"PRId64"\n", i, (int64_t)y[ i ] );
}
}

31 changes: 5 additions & 26 deletions lib/node_modules/@stdlib/blas/ext/base/ssort2ins/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,14 @@

'use strict';

var round = require( '@stdlib/math/base/special/round' );
var randu = require( '@stdlib/random/base/randu' );
var Float32Array = require( '@stdlib/array/float32' );
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
var filledarrayBy = require( '@stdlib/array/filled-by' );
var ssort2ins = require( './../lib' );

var rand;
var sign;
var x;
var y;
var i;

x = new Float32Array( 10 );
y = new Float32Array( 10 ); // index array
for ( i = 0; i < x.length; i++ ) {
if ( randu() < 0.2 ) {
x[ i ] = NaN;
} else {
rand = round( randu()*100.0 );
sign = randu();
if ( sign < 0.5 ) {
sign = -1.0;
} else {
sign = 1.0;
}
x[ i ] = sign * rand;
}
y[ i ] = i;
}
var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) );
console.log( x );

var y = filledarrayBy( x.length, 'float32', discreteUniform( 0, 10 ) );
console.log( y );

ssort2ins( x.length, -1.0, x, -1, y, -1 );
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( './ssort2ins.native.js' );


Expand Down Expand Up @@ -56,20 +57,19 @@ var addon = require( './ssort2ins.native.js' );
function ssort2ins( N, order, x, strideX, offsetX, y, strideY, offsetY ) {
var viewX;
var viewY;
var flg;
var flg = 1.0;

flg = 1.0;
offsetX = minViewBufferIndex( N, strideX, offsetX );
offsetY = minViewBufferIndex( N, strideY, offsetY );
if ( strideX < 0 ) {
flg *= -1.0; // reversing order
order *= -1.0;
strideX *= -1;
offsetX -= (N-1) * strideX;
}
if ( strideY < 0 ) {
offsetY += (N-1) * strideY;
}
viewX = new Float32Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offsetX), x.length-offsetX ); // eslint-disable-line max-len
viewY = new Float32Array( y.buffer, y.byteOffset+(y.BYTES_PER_ELEMENT*offsetY), y.length-offsetY ); // eslint-disable-line max-len

viewX = offsetView( x, offsetX );
viewY = offsetView( y, offsetY );

addon( N, order, viewX, strideX, viewY, flg*strideY );
return x;
}
Expand Down
121 changes: 80 additions & 41 deletions lib/node_modules/@stdlib/blas/ext/base/ssort2ins/manifest.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,82 @@
{
"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/ssort2ins.c"
],
"include": [
"./include"
],
"libraries": [
"-lm"
],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nanf",
"@stdlib/math/base/assert/is-negative-zerof"
]
}
]
"options": {
"task": "build"
},
"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": [
{
"task": "build",
"src": [
"./src/ssort2ins.c"
],
"include": [
"./include"
],
"libraries": [
"-lm"
],
"libpath": [],
"dependencies": [
"@stdlib/napi/export",
"@stdlib/napi/argv",
"@stdlib/napi/argv-int64",
"@stdlib/napi/argv-double",
"@stdlib/napi/argv-strided-float32array",
"@stdlib/math/base/assert/is-nanf",
"@stdlib/math/base/assert/is-negative-zerof"
]
},
{
"task": "benchmark",
"src": [
"./src/ssort2ins.c"
],
"include": [
"./include"
],
"libraries": [
"-lm"
],
"libpath": [],
"dependencies": []
},
{
"task": "examples",
"src": [
"./src/ssort2ins.c"
],
"include": [
"./include"
],
"libraries": [
"-lm"
],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nanf",
"@stdlib/math/base/assert/is-negative-zerof"
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,7 @@
"single",
"float32array"
],
"__stdlib__": {}
"__stdlib__": {
"wasm": false
}
}
Loading
Loading