Expand a dimension over multiple dimensions.
var unflattenShape = require( '@stdlib/ndarray/base/unflatten-shape' );Expands a dimension over multiple dimensions.
var sh = unflattenShape( [ 6, 2, 1 ], 0, [ 3, 2 ] );
// returns [ 3, 2, 2, 1 ]The function accepts the following parameters:
- shape: array shape.
- dim: dimension to be unflattened. If provided an integer less than zero, the dimension index is resolved relative to the last dimension, with the last dimension corresponding to the value
-1. - sizes: new shape of the unflattened dimension.
Expands a dimension over multiple dimensions and assigns results to a provided output array.
var o = [ 0, 0, 0, 0 ];
var out = unflattenShape.assign( [ 6, 2, 1 ], 0, [ 3, 2 ], o );
// returns [ 3, 2, 2, 1 ]
var bool = ( out === o );
// returns trueThe function accepts the following parameters:
- shape: array shape.
- dim: dimension to be unflattened. If provided an integer less than zero, the dimension index is resolved relative to the last dimension, with the last dimension corresponding to the value
-1. - sizes: new shape of the unflattened dimension.
- out: output array.
var unflattenShape = require( '@stdlib/ndarray/base/unflatten-shape' );
var out = unflattenShape( [ 2, 4, 1 ], 1, [ 2, 2 ] );
// returns [ 2, 2, 2, 1 ]
out = unflattenShape( [ 2, 4, 1 ], 1, [ 2, 1, 2 ] );
// returns [ 2, 2, 1, 2, 1 ]
out = unflattenShape( [ 2, 4, 1 ], 1, [ 2, 1, 1, 2 ] );
// returns [ 2, 2, 1, 1, 2, 1 ]