@@ -24,6 +24,7 @@ import any = require( './../../../base/any' );
2424import anyBy = require( './../../../base/any-by' ) ;
2525import assert = require( './../../../base/assert' ) ;
2626import assign = require( './../../../base/assign' ) ;
27+ import atleastnd = require( './../../../base/atleastnd' ) ;
2728import binary = require( './../../../base/binary' ) ;
2829import binaryInputCastingDataType = require( './../../../base/binary-input-casting-dtype' ) ;
2930import binaryLoopOrder = require( './../../../base/binary-loop-interchange-order' ) ;
@@ -163,6 +164,7 @@ import toFlippedud = require( './../../../base/to-flippedud' );
163164import toNormalizedIndices = require( './../../../base/to-normalized-indices' ) ;
164165import toReversed = require( './../../../base/to-reversed' ) ;
165166import toReversedDimension = require( './../../../base/to-reversed-dimension' ) ;
167+ import toTransposed = require( './../../../base/to-transposed' ) ;
166168import toUniqueNormalizedIndices = require( './../../../base/to-unique-normalized-indices' ) ;
167169import transpose = require( './../../../base/transpose' ) ;
168170import unary = require( './../../../base/unary' ) ;
@@ -180,6 +182,7 @@ import unaryReduceSubarrayBy = require( './../../../base/unary-reduce-subarray-b
180182import unaryStrided1dDispatch = require( './../../../base/unary-strided1d-dispatch' ) ;
181183import unaryStrided1dDispatchFactory = require( './../../../base/unary-strided1d-dispatch-factory' ) ;
182184import unaryBlockSize = require( './../../../base/unary-tiling-block-size' ) ;
185+ import unflattenShape = require( './../../../base/unflatten-shape' ) ;
183186import vind2bind = require( './../../../base/vind2bind' ) ;
184187import wrapIndex = require( './../../../base/wrap-index' ) ;
185188import zeros = require( './../../../base/zeros' ) ;
@@ -301,6 +304,27 @@ interface Namespace {
301304 */
302305 assign : typeof assign ;
303306
307+ /**
308+ * Converts a list of values (scalars and/or ndarrays) to ndarrays having at least a specified number of dimensions.
309+ *
310+ * @param ndims - minimum number of dimensions
311+ * @param arrays - array-like object containing a list of scalars and/or ndarrays
312+ * @returns an array of ndarrays
313+ *
314+ * @example
315+ * var array = require( './../../../array' );
316+ *
317+ * var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ] );
318+ * // returns <ndarray>[ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ] ]
319+ *
320+ * var y = array( [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] );
321+ * // returns <ndarray>[ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ]
322+ *
323+ * var out = ns.atleastnd( 3, [ x, y ] );
324+ * // returns [ <ndarray>, <ndarray> ]
325+ */
326+ atleastnd : typeof atleastnd ;
327+
304328 /**
305329 * Applies a binary callback to elements in input ndarrays and assigns results to elements in an output ndarray.
306330 *
@@ -3378,14 +3402,14 @@ interface Namespace {
33783402 quinaryBlockSize : typeof quinaryBlockSize ;
33793403
33803404 /**
3381- * Returns an array without singleton dimensions.
3405+ * Returns an ndarray without singleton dimensions.
33823406 *
33833407 * ## Notes
33843408 *
3385- * - If a provided ndarray does not have any singleton dimensions, the function returns the provided ndarray unchanged.
3386- * - If a provided ndarray does have singleton dimensions, the function returns a new ndarray view.
3409+ * - The function always returns a new ndarray instance even if the input ndarray does not contain any singleton dimensions.
33873410 *
33883411 * @param x - input array
3412+ * @param writable - boolean indicating whether a returned array should be writable
33893413 * @returns squeezed array
33903414 *
33913415 * @example
@@ -3394,28 +3418,10 @@ interface Namespace {
33943418 * var x = array( [ [ 1, 2 ], [ 3, 4 ] ], {
33953419 * 'ndmin': 5
33963420 * });
3397- * // returns <ndarray>
3398- *
3399- * var shx = x.shape;
3400- * // returns [ 1, 1, 1, 2, 2 ]
3401- *
3402- * var y = ns.removeSingletonDimensions( x );
3403- * // returns <ndarray>
3404- *
3405- * var shy = y.shape;
3406- * // returns [ 2, 2 ]
3407- *
3408- * var v = y.get( 0, 0 );
3409- * // returns 1
3410- *
3411- * v = y.get( 0, 1 );
3412- * // returns 2
3413- *
3414- * v = y.get( 1, 0 );
3415- * // returns 3
3421+ * // returns <ndarray>[ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]
34163422 *
3417- * v = y.get( 1, 1 );
3418- * // returns 4
3423+ * var y = ns.removeSingletonDimensions( x, false );
3424+ * // returns <ndarray>[ [ 1, 2 ], [ 3, 4 ] ]
34193425 */
34203426 removeSingletonDimensions : typeof removeSingletonDimensions ;
34213427
@@ -4598,6 +4604,23 @@ interface Namespace {
45984604 */
45994605 toReversedDimension : typeof toReversedDimension ;
46004606
4607+ /**
4608+ * Returns a new ndarray containing the elements of an input ndarray but whose last two dimensions are transposed.
4609+ *
4610+ * @param x - input array
4611+ * @returns output ndarray
4612+ *
4613+ * @example
4614+ * var array = require( './../../../array' );
4615+ *
4616+ * var x = array( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] );
4617+ * // returns <ndarray>[ [ 1, 2, 3 ], [ 4, 5, 6 ] ]
4618+ *
4619+ * var out = ns.toTransposed( x );
4620+ * // returns <ndarray>[ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]
4621+ */
4622+ toTransposed : typeof toTransposed ;
4623+
46014624 /**
46024625 * Returns a list of unique indices after normalizing to the interval `[0,max]`.
46034626 *
@@ -5198,6 +5221,29 @@ interface Namespace {
51985221 */
51995222 unaryBlockSize : typeof unaryBlockSize ;
52005223
5224+ /**
5225+ * Expands a dimension over multiple dimensions.
5226+ *
5227+ * @param shape - array shape
5228+ * @param dim - dimension to be unflattened
5229+ * @param sizes - new shape of the unflattened dimension
5230+ * @returns unflattened shape
5231+ *
5232+ * @example
5233+ * var sh = ns.unflattenShape( [ 6, 2, 1 ], 0, [ 3, 2 ] );
5234+ * // returns [ 3, 2, 2, 1 ]
5235+ *
5236+ * @example
5237+ * var o = [ 0, 0, 0, 0 ];
5238+ *
5239+ * var out = ns.unflattenShape.assign( [ 6, 2, 1 ], 0, [ 3, 2 ], o );
5240+ * // returns [ 3, 2, 2, 1 ]
5241+ *
5242+ * var bool = ( out === o );
5243+ * // returns true
5244+ */
5245+ unflattenShape : typeof unflattenShape ;
5246+
52015247 /**
52025248 * Converts a linear index in an array view to a linear index in an underlying data buffer.
52035249 *
0 commit comments