Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fad77ea
fix: remove extra bracket spacing in test.isamax.js (#8357)
anujmishra03 Nov 3, 2025
98ac26e
trigger CI
anujmishra03 Nov 3, 2025
338d5dc
style: remove whitespace
kgryte Nov 3, 2025
5b59907
fix: address off-by-one bug
kgryte Nov 1, 2025
49f8acd
fix: address off-by-one bug
kgryte Nov 1, 2025
d0f2211
fix: address off-by-one bug
kgryte Nov 1, 2025
f997591
fix: address off-by-one bug
kgryte Nov 1, 2025
b15a5f0
feat: add `ndarray/base/some`
headlessNode Nov 1, 2025
ff2b861
test: fix descriptions
kgryte Nov 2, 2025
15ec4fb
docs: update examples
kgryte Nov 2, 2025
6943caa
docs: remove incorrect comment
kgryte Nov 2, 2025
3a25df5
build: account for additional declaration patterns
kgryte Nov 2, 2025
93a6944
feat: add `blas/ext/to-sortedhp`
headlessNode Nov 2, 2025
92a2de1
docs: update Markdown stdlib package URLs
stdlib-bot Nov 3, 2025
0a9b8a3
chore: add structured package data for `math/base/special/sech`
manvith2003 Nov 3, 2025
3020896
chore: add structured package data for `math/base/special/signum`
manvith2003 Nov 3, 2025
b62f52e
chore: add structured package data for `math/base/special/signumf`
manvith2003 Nov 3, 2025
45e7fe9
chore: add structured package data for `math/base/special/secd`
manvith2003 Nov 3, 2025
be9b22b
chore: add structured package data for `math/base/special/secdf`
manvith2003 Nov 3, 2025
1d62fb5
chore: add structured package data for `math/base/special/secf`
manvith2003 Nov 3, 2025
5c77273
chore: add structured package data for `math/base/special/hacoversin`
nakul-krishnakumar Nov 3, 2025
92d04cb
chore: add structured package data for `math/base/special/haversin`
nakul-krishnakumar Nov 3, 2025
52ce4b3
chore: add structured package data for `math/base/special/factoriallnf`
nakul-krishnakumar Nov 3, 2025
d9f9dd2
chore: add structured package data for `math/base/special/versin`
nakul-krishnakumar Nov 3, 2025
db3a42f
chore: add structured package data for `math/base/special/cceilf`
nakul-krishnakumar Nov 3, 2025
0e7e207
chore: add structured package data for `math/base/special/round`
Orthodox-64 Nov 3, 2025
6699064
chore: add structured package data for `math/base/special/round2`
Orthodox-64 Nov 3, 2025
491757b
chore: add structured package data for `math/base/special/floor`
Payal-Goswami Nov 3, 2025
8c155ff
chore: fix C lint errors
GeoDaoyu Nov 3, 2025
c222218
feat: update math scaffold databases
stdlib-bot Nov 3, 2025
f0d9394
chore: fix EditorConfig lint errors
sujalc879 Nov 3, 2025
32a5730
feat: add `ndarray/concat`
headlessNode Nov 3, 2025
cba4e23
refactor: pass ndarray view to internal function
kgryte Nov 3, 2025
bbda71d
fix(stats/halfnormal): correct PDF implementation and adjust test tol…
anujmishra03 Nov 6, 2025
f5af2f3
feat(stats/halfnormal): add PDF implementation and tests
anujmishra03 Nov 6, 2025
34be4cd
docs(stats/halfnormal): fix require path in README example
anujmishra03 Nov 6, 2025
1af2a64
chore(stats/halfnormal): add missing license headers
anujmishra03 Nov 6, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ result = linter.verify( code, {
});
console.log( result );
/* =>
[
{
'ruleId': 'no-dynamic-require',
'severity': 2,
'message': 'require() calls should only use string literals',
'line': 2,
'column': 15,
'nodeType': 'CallExpression',
'source': 'var betainc = require( pkg );',
'endLine': 2,
'endColumn': 29
}
]
[
{
'ruleId': 'no-dynamic-require',
'severity': 2,
'message': 'require() calls should only use string literals',
'line': 2,
'column': 15,
'nodeType': 'CallExpression',
'source': 'var betainc = require( pkg );',
'endLine': 2,
'endColumn': 29
}
]
*/
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var RE_DECLARE_CLASS = /declare\s+class\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s/;
var RE_DECLARE_CONST = /declare\s+const\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*:/;

// Regular expression to match variable declarations with interface types such as "declare var ctor: Int32Vector;" (captures variable name and interface name):
var RE_DECLARE_VAR_INTERFACE = /declare\s+var\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*:\s*([A-Z][a-zA-Z0-9_$]*)/;
var RE_DECLARE_VAR_INTERFACE = /declare\s+(?:var|const)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*:\s*([A-Z][a-zA-Z0-9_$]*)/;


// MAIN //
Expand Down
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/blas/base/isamax/test/test.isamax.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ tape( 'the function finds the index of the element with the maximum absolute val
idx = isamax( 4, x, 1 );
t.strictEqual( idx, expected, 'returns expected value' );

x = new Float32Array( [
x = new Float32Array([
0.2, // 1
-0.6, // 2
0.3, // 3
5.0,
5.0
] );
]);
expected = 1;

idx = isamax( 3, x, 1 );
Expand All @@ -77,11 +77,11 @@ tape( 'if provided an `N` parameter less than `1`, the function returns `-1`', f
var idx;
var x;

x = new Float32Array( [
x = new Float32Array([
1.0,
2.0,
3.0
] );
]);
expected = -1;

idx = isamax( 0, x, 1 );
Expand Down
2 changes: 0 additions & 2 deletions lib/node_modules/@stdlib/blas/ext/sorthp/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,3 @@ var main = require( './main.js' );
// EXPORTS //

module.exports = main;

// exports: { "assign": "main.assign" }
4 changes: 2 additions & 2 deletions lib/node_modules/@stdlib/blas/ext/sorthp/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ tape( 'the function throws an error if provided a first argument which is not an
}
});

tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a support string', function test( t ) {
tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a supported string', function test( t ) {
var values;
var x;
var i;
Expand Down Expand Up @@ -366,7 +366,7 @@ tape( 'the function throws an error if provided a `sortOrder` argument which is
}
});

tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a support string (options)', function test( t ) {
tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a supported string (options)', function test( t ) {
var values;
var x;
var i;
Expand Down
245 changes: 245 additions & 0 deletions lib/node_modules/@stdlib/blas/ext/to-sortedhp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
<!--

@license Apache-2.0

Copyright (c) 2025 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.

-->

# toSortedhp

> Return a new [ndarray][@stdlib/ndarray/ctor] containing the elements of an input [ndarray][@stdlib/ndarray/ctor] sorted along one or more [ndarray][@stdlib/ndarray/ctor] dimensions using heapsort.

<section class="usage">

## Usage

```javascript
var toSortedhp = require( '@stdlib/blas/ext/to-sortedhp' );
```

#### toSortedhp( x\[, sortOrder]\[, options] )

Returns a new [ndarray][@stdlib/ndarray/ctor] containing the elements of an input [ndarray][@stdlib/ndarray/ctor] sorted along one or more [ndarray][@stdlib/ndarray/ctor] dimensions using heapsort.

```javascript
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var array = require( '@stdlib/ndarray/array' );

var x = array( [ -1.0, 2.0, -3.0 ] );

var y = toSortedhp( x );
// returns <ndarray>

var arr = ndarray2array( y );
// returns [ -3.0, -1.0, 2.0 ]
```

The function has the following parameters:

- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have a real-valued or "generic" [data type][@stdlib/ndarray/dtypes].
- **sortOrder**: sort order (_optional_). May be either a scalar value, string, or an [ndarray][@stdlib/ndarray/ctor] having a real-valued or "generic" [data type][@stdlib/ndarray/dtypes]. If provided an [ndarray][@stdlib/ndarray/ctor], the value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the complement of the shape defined by `options.dims`. For example, given the input shape `[2, 3, 4]` and `options.dims=[0]`, an [ndarray][@stdlib/ndarray/ctor] sort order must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape `[3, 4]`. Similarly, when performing the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor], an [ndarray][@stdlib/ndarray/ctor] sort order must be a zero-dimensional [ndarray][@stdlib/ndarray/ctor]. By default, the sort order is `1` (i.e., increasing order).
- **options**: function options (_optional_).

The function accepts the following options:

- **dims**: list of dimensions over which to perform operation. If not provided, the function performs the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor].
- **dtype**: output [ndarray][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes].

By default, the function sorts elements in increasing order. To sort in a different order, provide a `sortOrder` argument.

```javascript
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var array = require( '@stdlib/ndarray/array' );

var x = array( [ -1.0, 2.0, -3.0 ] );

var y = toSortedhp( x, -1.0 );
// returns <ndarray>

var arr = ndarray2array( y );
// returns [ 2.0, -1.0, -3.0 ]
```

In addition to numeric values, one can specify the sort order via one of the following string literals: `'ascending'`, `'asc'`, `'descending'`, or `'desc'`. The first two literals indicate to sort in ascending (i.e., increasing) order. The last two literals indicate to sort in descending (i.e., decreasing) order.

```javascript
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var array = require( '@stdlib/ndarray/array' );

var x = array( [ -1.0, 2.0, -3.0 ] );

// Sort in ascending order:
var y = toSortedhp( x, 'asc' );
// returns <ndarray>

var arr = ndarray2array( y );
// returns [ -3.0, -1.0, 2.0 ]

// Sort in descending order:
y = toSortedhp( x, 'descending' );
// returns <ndarray>

arr = ndarray2array( y );
// returns [ 2.0, -1.0, -3.0 ]
```

By default, the function performs the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor]. To perform the operation over specific dimensions, provide a `dims` option.

```javascript
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var array = require( '@stdlib/ndarray/array' );

var x = array( [ -1.0, 2.0, -3.0, 4.0 ], {
'shape': [ 2, 2 ],
'order': 'row-major'
});

var v = ndarray2array( x );
// returns [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ]

var y = toSortedhp( x, {
'dims': [ 0 ]
});
// returns <ndarray>

v = ndarray2array( y );
// returns [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ]
```

To specify the output [ndarray][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes], provide a `dtype` option.

```javascript
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var array = require( '@stdlib/ndarray/array' );

var x = array( [ -1.0, 2.0, -3.0 ] );

var y = toSortedhp( x, {
'dtype': 'float32'
});
// returns <ndarray>

var arr = ndarray2array( y );
// returns [ -3.0, -1.0, 2.0 ]
```

#### toSortedhp.assign( x, out\[, sortOrder]\[, options] )

Sorts the elements of an input [ndarray][@stdlib/ndarray/ctor] along one or more [ndarray][@stdlib/ndarray/ctor] dimensions using heapsort and assigns the results to an output [ndarray][@stdlib/ndarray/ctor].

```javascript
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var zeros = require( '@stdlib/ndarray/zeros' );
var array = require( '@stdlib/ndarray/array' );

var x = array( [ -1.0, 2.0, -3.0 ] );
var y = zeros( [ 3 ] );

var out = toSortedhp.assign( x, y );
// returns <ndarray>

var arr = ndarray2array( out );
// returns [ -3.0, -1.0, 2.0 ]

var bool = ( y === out );
// returns true
```

The function has the following parameters:

- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have a real-valued or "generic" [data type][@stdlib/ndarray/dtypes].
- **out**: output [ndarray][@stdlib/ndarray/ctor]. Must have a real-valued or "generic" [data type][@stdlib/ndarray/dtypes].
- **sortOrder**: sort order (_optional_). May be either a scalar value, string, or an [ndarray][@stdlib/ndarray/ctor] having a real-valued or "generic" [data type][@stdlib/ndarray/dtypes]. If provided an [ndarray][@stdlib/ndarray/ctor], the value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the complement of the shape defined by `options.dims`. For example, given the input shape `[2, 3, 4]` and `options.dims=[0]`, an [ndarray][@stdlib/ndarray/ctor] sort order must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape `[3, 4]`. Similarly, when performing the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor], an [ndarray][@stdlib/ndarray/ctor] sort order must be a zero-dimensional [ndarray][@stdlib/ndarray/ctor]. By default, the sort order is `1` (i.e., increasing order).
- **options**: function options (_optional_).

The function accepts the following options:

- **dims**: list of dimensions over which to perform operation. If not provided, the function performs the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor].

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input [ndarray][@stdlib/ndarray/ctor] is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input [ndarray][@stdlib/ndarray/ctor] is sorted in **increasing** order. If `sortOrder == 0.0`, the input [ndarray][@stdlib/ndarray/ctor] is left 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 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)`.
- The algorithm is **unstable**, meaning that the algorithm may change the order of [ndarray][@stdlib/ndarray/ctor] elements which are equal or equivalent (e.g., `NaN` values).
- The function iterates over [ndarray][@stdlib/ndarray/ctor] elements according to the memory layout of the input [ndarray][@stdlib/ndarray/ctor]. Accordingly, performance degradation is possible when operating over multiple dimensions of a large non-contiguous multi-dimensional input [ndarray][@stdlib/ndarray/ctor]. In such scenarios, one may want to copy an input [ndarray][@stdlib/ndarray/ctor] to contiguous memory before sorting.

</section>

<!-- /.notes -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var ndarray = require( '@stdlib/ndarray/ctor' );
var toSortedhp = require( '@stdlib/blas/ext/to-sortedhp' );

// Generate an array of random numbers:
var xbuf = discreteUniform( 25, -20, 20, {
'dtype': 'generic'
});

// Wrap in an ndarray:
var x = new ndarray( 'generic', xbuf, [ 5, 5 ], [ 5, 1 ], 0, 'row-major' );
console.log( ndarray2array( x ) );

// Perform operation:
var out = toSortedhp( x, {
'dims': [ 0 ]
});

// Print the results:
console.log( ndarray2array( out ) );
```

</section>

<!-- /.examples -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/ctor

[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/dtypes

[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/broadcast-shapes

</section>

<!-- /.links -->
Loading