reducedDimensions
Return a list of reduced dimensions in an un-normalized
MultiSlice
object.
In a multi-axis indexing expression (e.g., '1,:,2,:,0:10:1'), a non-reduced dimension corresponds to a dimension which is retained in the slice result. Only integer indexing expressions (e.g., only the first and third dimensions in '1,:,2,:,0:10:1') result in dimension reduction; slices always retain respective dimensions, even if a slice is empty or only selects a single element.
Usage
var reducedDimensions = require( '@stdlib/slice/base/reduced-dimensions' );
reducedDimensions( slice )
Returns a list of reduced dimensions in an un-normalized MultiSlice
object.
var MultiSlice = require( '@stdlib/slice/multi' );
var Slice = require( '@stdlib/slice/ctor' );
var s = new MultiSlice( 1, null, 2, void 0, new Slice( 0, 10, 1 ) );
// returns <MultiSlice>
var indices = reducedDimensions( s );
// returns [ 0, 2 ]
Examples
var S = require( '@stdlib/slice/ctor' );
var MultiSlice = require( '@stdlib/slice/multi' );
var reducedDimensions = require( '@stdlib/slice/base/reduced-dimensions' );
var s = new MultiSlice( null, S(), -1 );
var out = reducedDimensions( s );
console.log( '%s => [%s]', s.toString(), out.join( ',' ) );
s = new MultiSlice( null );
out = reducedDimensions( s );
console.log( '%s => [%s]', s.toString(), out.join( ',' ) );
s = new MultiSlice( S( -1, null, -1 ), 3 );
out = reducedDimensions( s );
console.log( '%s => [%s]', s.toString(), out.join( ',' ) );
s = new MultiSlice( 2, S( -10, -2, 2 ), 3, null );
out = reducedDimensions( s );
console.log( '%s => [%s]', s.toString(), out.join( ',' ) );
s = new MultiSlice( S( 1, 20, 2 ), S( null, null, -1 ) );
out = reducedDimensions( s );
console.log( '%s => [%s]', s.toString(), out.join( ',' ) );