Skip to content

Commit 22f0eef

Browse files
committed
Auto-generated commit
1 parent 89b87e1 commit 22f0eef

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
##### Features
2222

23+
- [`e661213`](https://github.com/stdlib-js/stdlib/commit/e66121352ef767cdb87d19e938b1eccf7970fa3a) - update namespace TypeScript declarations [(#4706)](https://github.com/stdlib-js/stdlib/pull/4706)
2324
- [`741b6f1`](https://github.com/stdlib-js/stdlib/commit/741b6f1df8ce11e77fb22c279cee6bbae3323176) - add `spreadDimensions` to namespace
2425
- [`908239e`](https://github.com/stdlib-js/stdlib/commit/908239e7cc6b4b3e260d0cc1f5aebb9af35d83c6) - add `toUniqueNormalizedIndices` to namespace
2526
- [`524e854`](https://github.com/stdlib-js/stdlib/commit/524e854202862d5b37d66470d719fac1270e33c1) - add `toNormalizedIndices` to namespace
@@ -64,6 +65,7 @@
6465

6566
##### Features
6667

68+
- [`e661213`](https://github.com/stdlib-js/stdlib/commit/e66121352ef767cdb87d19e938b1eccf7970fa3a) - update namespace TypeScript declarations [(#4706)](https://github.com/stdlib-js/stdlib/pull/4706)
6769
- [`a94dcea`](https://github.com/stdlib-js/stdlib/commit/a94dceaa9469c774ee4622567e4c15a15e215bcf) - add `isColumnMajorString` to namespace
6870
- [`5e1be08`](https://github.com/stdlib-js/stdlib/commit/5e1be08ff661fb981dc4a91c2e9d37d7396327f5) - add `isRowMajorString` to namespace
6971
- [`8b1548f`](https://github.com/stdlib-js/stdlib/commit/8b1548fb45c1ff131f5edac20cb984344a2d28ec) - update namespace TypeScript declarations [(#3190)](https://github.com/stdlib-js/stdlib/pull/3190)
@@ -754,6 +756,7 @@ A total of 3 people contributed to this release. Thank you to the following cont
754756

755757
<details>
756758

759+
- [`e661213`](https://github.com/stdlib-js/stdlib/commit/e66121352ef767cdb87d19e938b1eccf7970fa3a) - **feat:** update namespace TypeScript declarations [(#4706)](https://github.com/stdlib-js/stdlib/pull/4706) _(by stdlib-bot)_
757760
- [`cff470f`](https://github.com/stdlib-js/stdlib/commit/cff470f9608165100c8c122fce70c40b1af864ec) - **docs:** update namespace table of contents (#4708) _(by stdlib-bot, Planeshifter)_
758761
- [`741b6f1`](https://github.com/stdlib-js/stdlib/commit/741b6f1df8ce11e77fb22c279cee6bbae3323176) - **feat:** add `spreadDimensions` to namespace _(by Athan Reines)_
759762
- [`3767255`](https://github.com/stdlib-js/stdlib/commit/3767255c7cfe85f09cea5c007e21297cd628245d) - **feat:** add `ndarray/base/spread-dimensions` _(by Athan Reines)_

docs/types/index.d.ts

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import ndims = require( '@stdlib/ndarray-base-ndims' );
7676
import nextCartesianIndex = require( '@stdlib/ndarray-base-next-cartesian-index' );
7777
import nonsingletonDimensions = require( '@stdlib/ndarray-base-nonsingleton-dimensions' );
7878
import normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' );
79+
import normalizeIndices = require( '@stdlib/ndarray-base-normalize-indices' );
7980
import nullary = require( '@stdlib/ndarray-base-nullary' );
8081
import nullaryLoopOrder = require( '@stdlib/ndarray-base-nullary-loop-interchange-order' );
8182
import nullaryBlockSize = require( '@stdlib/ndarray-base-nullary-tiling-block-size' );
@@ -102,13 +103,16 @@ import sliceDimensionFrom = require( '@stdlib/ndarray-base-slice-dimension-from'
102103
import sliceDimensionTo = require( '@stdlib/ndarray-base-slice-dimension-to' );
103104
import sliceFrom = require( '@stdlib/ndarray-base-slice-from' );
104105
import sliceTo = require( '@stdlib/ndarray-base-slice-to' );
106+
import spreadDimensions = require( '@stdlib/ndarray-base-spread-dimensions' );
105107
import stride = require( '@stdlib/ndarray-base-stride' );
106108
import strides = require( '@stdlib/ndarray-base-strides' );
107109
import strides2offset = require( '@stdlib/ndarray-base-strides2offset' );
108110
import strides2order = require( '@stdlib/ndarray-base-strides2order' );
109111
import sub2ind = require( '@stdlib/ndarray-base-sub2ind' );
110112
import ndarray2array = require( '@stdlib/ndarray-base-to-array' );
113+
import toNormalizedIndices = require( '@stdlib/ndarray-base-to-normalized-indices' );
111114
import toReversed = require( '@stdlib/ndarray-base-to-reversed' );
115+
import toUniqueNormalizedIndices = require( '@stdlib/ndarray-base-to-unique-normalized-indices' );
112116
import transpose = require( '@stdlib/ndarray-base-transpose' );
113117
import unary = require( '@stdlib/ndarray-base-unary' );
114118
import unaryBy = require( '@stdlib/ndarray-base-unary-by' );
@@ -1865,6 +1869,27 @@ interface Namespace {
18651869
*/
18661870
normalizeIndex: typeof normalizeIndex;
18671871

1872+
/**
1873+
* Normalizes a list of indices to the interval `[0,max]`.
1874+
*
1875+
* ## Notes
1876+
*
1877+
* - If provided an out-of-bounds index, the function returns `null`.
1878+
* - The function mutates the input array, even when provided an out-of-bounds index.
1879+
*
1880+
* @param indices - indices
1881+
* @param max - maximum index
1882+
* @returns normalized indices or null
1883+
*
1884+
* @example
1885+
* var indices = ns.normalizeIndices( [ -2, 5 ], 10 );
1886+
* // returns [ 9, 5 ]
1887+
*
1888+
* indices = ns.normalizeIndices( [ -2, 15 ], 10 );
1889+
* // returns null
1890+
*/
1891+
normalizeIndices: typeof normalizeIndices;
1892+
18681893
/**
18691894
* Applies a nullary callback and assigns results to elements in an output ndarray.
18701895
*
@@ -2662,6 +2687,48 @@ interface Namespace {
26622687
*/
26632688
sliceTo: typeof sliceTo;
26642689

2690+
/**
2691+
* Expands the shape of an array to a specified dimensionality by spreading its dimensions to specified dimension indices and inserting dimensions of size one for the remaining dimensions.
2692+
*
2693+
* ## Notes
2694+
*
2695+
* - Each provided dimension index must reside on the interval `[-ndims, ndims-1]`. If provided a negative dimension index, the position at which to place a respective dimension is computed as `ndims + index`.
2696+
* - Provided dimension indices must resolve to normalized dimension indices arranged in ascending order.
2697+
*
2698+
* @param ndims - number of dimensions in the output array
2699+
* @param x - input array
2700+
* @param dims - dimension indices
2701+
* @returns output array
2702+
*
2703+
* @example
2704+
* var array = require( '@stdlib/ndarray-array' );
2705+
*
2706+
* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
2707+
* // returns <ndarray>
2708+
*
2709+
* var shx = x.shape;
2710+
* // returns [ 2, 2 ]
2711+
*
2712+
* var y = ns.spreadDimensions( 5, x, [ 1, 3 ] );
2713+
* // returns <ndarray>
2714+
*
2715+
* var shy = y.shape;
2716+
* // returns [ 1, 2, 1, 2, 1 ]
2717+
*
2718+
* var v = y.get( 0, 0, 0, 0, 0 );
2719+
* // returns 1
2720+
*
2721+
* v = y.get( 0, 0, 0, 1, 0 );
2722+
* // returns 2
2723+
*
2724+
* v = y.get( 0, 1, 0, 0, 0 );
2725+
* // returns 3
2726+
*
2727+
* v = y.get( 0, 1, 0, 1, 0 );
2728+
* // returns 4
2729+
*/
2730+
spreadDimensions: typeof spreadDimensions;
2731+
26652732
/**
26662733
* Returns the stride along a specified dimension for a provided ndarray.
26672734
*
@@ -2865,6 +2932,26 @@ interface Namespace {
28652932
*/
28662933
ndarray2array: typeof ndarray2array;
28672934

2935+
/**
2936+
* Normalizes a list of indices to the interval `[0,max]`.
2937+
*
2938+
* ## Notes
2939+
*
2940+
* - If provided an out-of-bounds index, the function normalizes the index to `-1`.
2941+
*
2942+
* @param indices - indices
2943+
* @param max - maximum index
2944+
* @returns normalized indices
2945+
*
2946+
* @example
2947+
* var indices = ns.toNormalizedIndices( [ -2, 5 ], 10 );
2948+
* // returns [ 9, 5 ]
2949+
*
2950+
* indices = ns.toNormalizedIndices( [ -2, 15 ], 10 );
2951+
* // returns [ 9, -1 ]
2952+
*/
2953+
toNormalizedIndices: typeof toNormalizedIndices;
2954+
28682955
/**
28692956
* Returns a new ndarray where the order of elements of an input ndarray is reversed along each dimension.
28702957
*
@@ -2901,6 +2988,26 @@ interface Namespace {
29012988
*/
29022989
toReversed: typeof toReversed;
29032990

2991+
/**
2992+
* Returns a list of unique indices after normalizing to the interval `[0,max]`.
2993+
*
2994+
* ## Notes
2995+
*
2996+
* - If provided an out-of-bounds index, the function returns `null`.
2997+
*
2998+
* @param indices - indices
2999+
* @param max - maximum index
3000+
* @returns normalized indices (or null)
3001+
*
3002+
* @example
3003+
* var indices = ns.toUniqueNormalizedIndices( [ -2, 5 ], 10 );
3004+
* // returns [ 9, 5 ]
3005+
*
3006+
* indices = ns.toUniqueNormalizedIndices( [ -2, 15 ], 10 );
3007+
* // returns null
3008+
*/
3009+
toUniqueNormalizedIndices: typeof toUniqueNormalizedIndices;
3010+
29043011
/**
29053012
* Transposes a matrix (or a stack of matrices).
29063013
*

0 commit comments

Comments
 (0)