Skip to content

Commit 0e87f72

Browse files
authored
Merge branch 'stdlib-js:develop' into nullary-strided1d-dispatch
2 parents f609398 + c63cbbc commit 0e87f72

File tree

321 files changed

+25825
-25
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

321 files changed

+25825
-25
lines changed

docs/talks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ limitations under the License.
3232
3333
<div class="image" align="center">
3434
<a title="The Future of Numerical Computing in JavaScript" href="https://gitnation.com/contents/the-future-of-numerical-computing-in-javascript">
35-
<img width="480" src="" alt="The Future of Numerical Computing in JavaScript">
35+
<img width="480" src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@5bee167f21165026dcf85c79048488ea384a9ede/docs/assets/talks/jsnation_2025_gunj_joshi.png" alt="The Future of Numerical Computing in JavaScript">
3636
</a>
3737
<br>
3838
</div>

lib/node_modules/@stdlib/blas/base/ggemv/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* var x = [ 1.0, 1.0, 1.0 ];
3131
* var y = [ 1.0, 1.0 ];
3232
*
33-
* dgemv( 'row-major', 'no-transpose', 2, 3, 1.0, A, 3, x, 1, 1.0, y, 1 );
33+
* ggemv( 'row-major', 'no-transpose', 2, 3, 1.0, A, 3, x, 1, 1.0, y, 1 );
3434
* // y => [ 7.0, 16.0 ]
3535
*
3636
* @example

lib/node_modules/@stdlib/blas/ext/base/dnanasumors/test/test.dnanasumors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ tape( 'main export is a function', function test( t ) {
3434
});
3535

3636
tape( 'the function has an arity of 3', function test( t ) {
37-
t.strictEqual( dnanasumors.length, 3, 'return expected value' );
37+
t.strictEqual( dnanasumors.length, 3, 'returns expected value' );
3838
t.end();
3939
});
4040

lib/node_modules/@stdlib/blas/ext/base/dnanasumors/test/test.dnanasumors.native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ tape( 'main export is a function', opts, function test( t ) {
4343
});
4444

4545
tape( 'the function has an arity of 3', opts, function test( t ) {
46-
t.strictEqual( dnanasumors.length, 3, 'return expected value' );
46+
t.strictEqual( dnanasumors.length, 3, 'returns expected value' );
4747
t.end();
4848
});
4949

lib/node_modules/@stdlib/blas/ext/base/dnanasumors/test/test.ndarray.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ tape( 'main export is a function', function test( t ) {
3434
});
3535

3636
tape( 'the function has an arity of 4', function test( t ) {
37-
t.strictEqual( dnanasumors.length, 4, 'return expected value' );
37+
t.strictEqual( dnanasumors.length, 4, 'returns expected value' );
3838
t.end();
3939
});
4040

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# gsorthp
22+
23+
> Sort a one-dimensional ndarray using heapsort.
24+
25+
<section class="intro">
26+
27+
</section>
28+
29+
<!-- /.intro -->
30+
31+
<section class="usage">
32+
33+
## Usage
34+
35+
```javascript
36+
var gsorthp = require( '@stdlib/blas/ext/base/ndarray/gsorthp' );
37+
```
38+
39+
#### gsorthp( arrays )
40+
41+
Sorts a one-dimensional ndarray using heapsort.
42+
43+
```javascript
44+
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
45+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
46+
var ndarray = require( '@stdlib/ndarray/base/ctor' );
47+
48+
var xbuf = [ 1.0, -2.0, 3.0, -4.0 ];
49+
var x = new ndarray( 'generic', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
50+
51+
var order = scalar2ndarray( 1.0, {
52+
'dtype': 'generic'
53+
});
54+
55+
var out = gsorthp( [ x, order ] );
56+
// returns <ndarray>
57+
58+
var arr = ndarray2array( out );
59+
// returns [ -4.0, -2.0, 1.0, 3.0 ]
60+
```
61+
62+
The function has the following parameters:
63+
64+
- **arrays**: array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray specifying the sort order.
65+
66+
</section>
67+
68+
<!-- /.usage -->
69+
70+
<section class="notes">
71+
72+
## Notes
73+
74+
- The input ndarray is sorted **in-place** (i.e., the input ndarray is **mutated**).
75+
- When the sort order is less than zero, the input ndarray is sorted in **decreasing** order. When the sort order is greater than zero, the input ndarray is sorted in **increasing** order. When the sort order is equal to zero, the input ndarray is left unchanged.
76+
77+
</section>
78+
79+
<!-- /.notes -->
80+
81+
<section class="examples">
82+
83+
## Examples
84+
85+
<!-- eslint no-undef: "error" -->
86+
87+
```javascript
88+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
89+
var ndarray = require( '@stdlib/ndarray/base/ctor' );
90+
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
91+
var ndarray2array = require( '@stdlib/ndarray/to-array' );
92+
var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' );
93+
var gsorthp = require( '@stdlib/blas/ext/base/ndarray/gsorthp' );
94+
95+
var xbuf = discreteUniform( 10, -100, 100, {
96+
'dtype': 'generic'
97+
});
98+
var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
99+
console.log( ndarray2array( x ) );
100+
101+
var order = scalar2ndarray( 1.0, {
102+
'dtype': 'generic'
103+
});
104+
console.log( 'Order:', ndarraylike2scalar( order ) );
105+
106+
gsorthp( [ x, order ] );
107+
console.log( ndarray2array( x ) );
108+
```
109+
110+
</section>
111+
112+
<!-- /.examples -->
113+
114+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
115+
116+
<section class="related">
117+
118+
</section>
119+
120+
<!-- /.related -->
121+
122+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
123+
124+
<section class="links">
125+
126+
</section>
127+
128+
<!-- /.links -->
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
25+
var pow = require( '@stdlib/math/base/special/pow' );
26+
var ndarray = require( '@stdlib/ndarray/base/ctor' );
27+
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
28+
var pkg = require( './../package.json' ).name;
29+
var gsorthp = require( './../lib' );
30+
31+
32+
// VARIABLES //
33+
34+
var options = {
35+
'dtype': 'generic'
36+
};
37+
38+
39+
// FUNCTIONS //
40+
41+
/**
42+
* Creates a benchmark function.
43+
*
44+
* @private
45+
* @param {PositiveInteger} len - array length
46+
* @returns {Function} benchmark function
47+
*/
48+
function createBenchmark( len ) {
49+
var order;
50+
var xbuf;
51+
var x;
52+
53+
xbuf = uniform( len, 0.0, 100.0, options );
54+
x = new ndarray( options.dtype, xbuf, [ len ], [ 1 ], 0, 'row-major' );
55+
56+
order = scalar2ndarray( -1.0, options );
57+
58+
return benchmark;
59+
60+
function benchmark( b ) {
61+
var out;
62+
var i;
63+
64+
b.tic();
65+
for ( i = 0; i < b.iterations; i++ ) {
66+
out = gsorthp( [ x, order ] );
67+
if ( out !== out ) {
68+
b.fail( 'should not return NaN' );
69+
}
70+
}
71+
b.toc();
72+
if ( out !== out ) {
73+
b.fail( 'should not return NaN' );
74+
}
75+
b.pass( 'benchmark finished' );
76+
b.end();
77+
}
78+
}
79+
80+
81+
// MAIN //
82+
83+
/**
84+
* Main execution sequence.
85+
*
86+
* @private
87+
*/
88+
function main() {
89+
var len;
90+
var min;
91+
var max;
92+
var f;
93+
var i;
94+
95+
min = 1; // 10^min
96+
max = 6; // 10^max
97+
98+
for ( i = min; i <= max; i++ ) {
99+
len = pow( 10, i );
100+
f = createBenchmark( len );
101+
bench( pkg+':len='+len, f );
102+
}
103+
}
104+
105+
main();
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
{{alias}}( arrays )
3+
Sorts a one-dimensional ndarray using heapsort.
4+
5+
When the sort order is less than zero, the input ndarray is sorted in
6+
decreasing order. When the sort order is greater than zero, the input
7+
ndarray is sorted in increasing order. When the sort order is equal to zero,
8+
the input ndarray is left unchanged.
9+
10+
The input ndarray is sorted in-place (i.e., the input ndarray is mutated).
11+
12+
Parameters
13+
----------
14+
arrays: ArrayLikeObject<ndarray>
15+
Array-like object containing a one-dimensional input ndarray and a
16+
zero-dimensional ndarray specifying the sort order.
17+
18+
Returns
19+
-------
20+
out: ndarray
21+
Input ndarray.
22+
23+
Examples
24+
--------
25+
> var xbuf = [ 1.0, -2.0, 3.0, -4.0 ];
26+
> var dt = 'generic';
27+
> var sh = [ xbuf.length ];
28+
> var sx = [ 1 ];
29+
> var ox = 0;
30+
> var ord = 'row-major';
31+
> var x = new {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord );
32+
> var o = {{alias:@stdlib/ndarray/from-scalar}}( 1.0 );
33+
> {{alias}}( [ x, o ] )
34+
<ndarray>
35+
> var data = x.data
36+
[ -4.0, -2.0, 1.0, 3.0 ]
37+
38+
See Also
39+
--------
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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+
// TypeScript Version: 4.1
20+
21+
/// <reference types="@stdlib/types"/>
22+
23+
import { typedndarray } from '@stdlib/types/ndarray';
24+
25+
/**
26+
* Sorts a one-dimensional ndarray using heapsort.
27+
*
28+
* ## Notes
29+
*
30+
* - When the sort order is less than zero, the input ndarray is sorted in **decreasing** order. When the sort order is greater than zero, the input ndarray is sorted in **increasing** order. When the sort order is equal to zero, the input ndarray is left unchanged.
31+
*
32+
* @param arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray specifying the sort order
33+
* @returns input ndarray
34+
*
35+
* @example
36+
* var ndarray2array = require( '@stdlib/ndarray/base/to-array' );
37+
* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
38+
* var ndarray = require( '@stdlib/ndarray/base/ctor' );
39+
*
40+
* var xbuf = [ 1.0, -2.0, 3.0, -4.0 ];
41+
* var x = new ndarray( 'generic', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
42+
*
43+
* var ord = scalar2ndarray( 1.0, {
44+
* 'dtype': 'generic'
45+
* });
46+
*
47+
* var out = gsorthp( [ x, ord ] );
48+
* // returns <ndarray>
49+
*
50+
* var arr = ndarra2array( out );
51+
* // returns [ -4.0, -2.0, 1.0, 3.0 ]
52+
*/
53+
declare function gsorthp<T = unknown>( arrays: [ typedndarray<T>, typedndarray<number> ] ): typedndarray<T>;
54+
55+
56+
// EXPORTS //
57+
58+
export = gsorthp;

0 commit comments

Comments
 (0)