Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Feb 8, 2025
1 parent fd1d84c commit 4dfcf1c
Show file tree
Hide file tree
Showing 18 changed files with 1,229 additions and 211 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ indent_style = tab
[*.{f,f.txt}]
indent_style = space
indent_size = 2
insert_final_newline = false

# Set properties for shell files:
[*.{sh,sh.txt}]
Expand Down
1 change: 0 additions & 1 deletion .github/.keepalive

This file was deleted.

44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,50 @@

> Package changelog.
<section class="release" id="unreleased">

## Unreleased (2025-02-08)

<section class="features">

### Features

- [`112b7ef`](https://github.com/stdlib-js/stdlib/commit/112b7ef36a44bc8b27ad757cc3099d2595aa8aaa) - add accessor arrays support and refactor `blas/ext/base/gsorthp` [(#5117)](https://github.com/stdlib-js/stdlib/pull/5117)

</section>

<!-- /.features -->

<section class="commits">

### Commits

<details>

- [`112b7ef`](https://github.com/stdlib-js/stdlib/commit/112b7ef36a44bc8b27ad757cc3099d2595aa8aaa) - **feat:** add accessor arrays support and refactor `blas/ext/base/gsorthp` [(#5117)](https://github.com/stdlib-js/stdlib/pull/5117) _(by Muhammad Haris)_

</details>

</section>

<!-- /.commits -->

<section class="contributors">

### Contributors

A total of 1 person contributed to this release. Thank you to this contributor:

- Muhammad Haris

</section>

<!-- /.contributors -->

</section>

<!-- /.release -->

<section class="release" id="v0.2.2">

## 0.2.2 (2024-07-28)
Expand Down
7 changes: 6 additions & 1 deletion CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Daniel Killenberger <[email protected]>
Daniel Yu <[email protected]>
Debashis Maharana <[email protected]>
Desh Deepak Kant <[email protected]>
Dev Goel <[email protected]>
Dhruv Arvind Singh <[email protected]>
Divyansh Seth <[email protected]>
Dominic Lim <[email protected]>
Dominik Moritz <[email protected]>
Expand All @@ -49,6 +51,7 @@ Joey Reed <[email protected]>
Jordan Gallivan <[email protected]>
Joris Labie <[email protected]>
Justin Dennison <[email protected]>
Karan Anand <[email protected]>
Karthik Prakash <[email protected]>
Kohantika Nath <[email protected]>
Krishnendu Das <[email protected]>
Expand All @@ -60,6 +63,7 @@ Marcus Fantham <[email protected]>
Matt Cochrane <[email protected]>
Mihir Pandit <[email protected]>
Milan Raj <[email protected]>
Mohammad Bin Aftab <[email protected]>
Mohammad Kaif <[email protected]>
Momtchil Momtchev <[email protected]>
Muhammad Haris <[email protected]>
Expand Down Expand Up @@ -117,10 +121,11 @@ UtkershBasnet <[email protected]>
Vaibhav Patel <[email protected]>
Varad Gupta <[email protected]>
Vinit Pandit <[email protected]>
Vivek maurya <[email protected].com>
Vivek Maurya <vm8118134@gmail.com>
Xiaochuan Ye <[email protected]>
Yaswanth Kosuru <[email protected]>
Yernar Yergaziyev <[email protected]>
olenkabilonizhka <[email protected]>
pranav-1720 <[email protected]>
rainn <[email protected]>
rei2hu <[email protected]>
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Copyright (c) 2016-2024 The Stdlib Authors.
Copyright (c) 2016-2025 The Stdlib Authors.
53 changes: 18 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ To view installation and usage instructions specific to each branch build, be su
var gsorthp = require( '@stdlib/blas-ext-base-gsorthp' );
```

#### gsorthp( N, order, x, stride )
#### gsorthp( N, order, x, strideX )

Sorts a strided array `x` using heapsort.
Sorts a strided array using heapsort.

```javascript
var x = [ 1.0, -2.0, 3.0, -4.0 ];
Expand All @@ -79,41 +79,36 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **order**: sort order. If `order < 0.0`, the input strided array is sorted in **decreasing** order. If `order > 0.0`, the input strided array is sorted in **increasing** order. If `order == 0.0`, the input strided array is left unchanged.
- **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
- **stride**: index increment.
- **strideX**: stride length.

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

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

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

gsorthp( N, -1.0, x, 2 );
gsorthp( 2, -1.0, x, 2 );
// x => [ 3.0, -2.0, 1.0, -4.0 ]
```

Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.

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

// Initial array...
var x0 = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );

// Create an offset view...
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var N = floor( x0.length/2 );

// Sort every other element...
gsorthp( N, -1.0, x1, 2 );
gsorthp( 2, -1.0, x1, 2 );
// x0 => <Float64Array>[ 1.0, 4.0, 3.0, 2.0 ]
```

#### gsorthp.ndarray( N, order, x, stride, offset )
#### gsorthp.ndarray( N, order, x, strideX, offsetX )

Sorts a strided array `x` using heapsort and alternative indexing semantics.
Sorts a strided array using heapsort and alternative indexing semantics.

```javascript
var x = [ 1.0, -2.0, 3.0, -4.0 ];
Expand All @@ -124,9 +119,9 @@ gsorthp.ndarray( x.length, 1.0, x, 1, 0 );

The function has the following additional parameters:

- **offset**: starting index.
- **offsetX**: 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:

```javascript
var x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];
Expand All @@ -144,6 +139,7 @@ gsorthp.ndarray( 3, 1.0, x, 1, x.length-3 );
## Notes

- If `N <= 0` or `order == 0.0`, both functions return `x` unchanged.
- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array-base/accessor`][@stdlib/array/base/accessor])
- The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`.
- The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first.
- The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`.
Expand All @@ -162,27 +158,12 @@ gsorthp.ndarray( 3, 1.0, x, 1, x.length-3 );
<!-- eslint no-undef: "error" -->

```javascript
var round = require( '@stdlib/math-base-special-round' );
var randu = require( '@stdlib/random-base-randu' );
var Float64Array = require( '@stdlib/array-float64' );
var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
var gsorthp = require( '@stdlib/blas-ext-base-gsorthp' );

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

x = new Float64Array( 10 );
for ( i = 0; i < x.length; i++ ) {
rand = round( randu()*100.0 );
sign = randu();
if ( sign < 0.5 ) {
sign = -1.0;
} else {
sign = 1.0;
}
x[ i ] = sign * rand;
}
var x = discreteUniform( 10, -100, 100, {
'dtype': 'float64'
});
console.log( x );

gsorthp( x.length, -1.0, x, -1 );
Expand Down Expand Up @@ -248,7 +229,7 @@ See [LICENSE][stdlib-license].

## Copyright

Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
Copyright &copy; 2016-2025. The Stdlib [Authors][stdlib-authors].

</section>

Expand Down Expand Up @@ -298,6 +279,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].

[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray

[@stdlib/array/base/accessor]: https://github.com/stdlib-js/array-base-accessor

[@williams:1964a]: https://doi.org/10.1145/512274.512284

[@floyd:1964a]: https://doi.org/10.1145/355588.365103
Expand Down
13 changes: 8 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4dfcf1c

Please sign in to comment.