nonreducedDimensions

Return a list of non-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 nonreducedDimensions = require( '@stdlib/slice/base/nonreduced-dimensions' );

nonreducedDimensions( slice )

Returns a list of non-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 = nonreducedDimensions( s );
// returns [ 1, 3, 4 ]

Examples

var S = require( '@stdlib/slice/ctor' );
var MultiSlice = require( '@stdlib/slice/multi' );
var nonreducedDimensions = require( '@stdlib/slice/base/nonreduced-dimensions' );

var s = new MultiSlice( null, S(), -1 );
var out = nonreducedDimensions( s );
console.log( '%s => [%s]', s.toString(), out.join( ',' ) );

s = new MultiSlice( null );
out = nonreducedDimensions( s );
console.log( '%s => [%s]', s.toString(), out.join( ',' ) );

s = new MultiSlice( S( -1, null, -1 ), 3 );
out = nonreducedDimensions( s );
console.log( '%s => [%s]', s.toString(), out.join( ',' ) );

s = new MultiSlice( 2, S( -10, -2, 2 ), 3, null );
out = nonreducedDimensions( s );
console.log( '%s => [%s]', s.toString(), out.join( ',' ) );

s = new MultiSlice( S( 1, 20, 2 ), S( null, null, -1 ) );
out = nonreducedDimensions( s );
console.log( '%s => [%s]', s.toString(), out.join( ',' ) );
Did you find this page helpful?