Return a read-only view of an input ndarray with singleton dimensions removed.
var removeSingletonDimensions = require( '@stdlib/ndarray/remove-singleton-dimensions' );Returns a read-only view of an input ndarray with singleton dimensions removed.
var array = require( '@stdlib/ndarray/array' );
// Create a 1x2x2 ndarray:
var x = array( [ [ [ 1, 2 ], [ 3, 4 ] ] ] );
// returns <ndarray>[ [ [ 1, 2 ], [ 3, 4 ] ] ]
// Remove singleton dimensions:
var y = removeSingletonDimensions( x );
// returns <ndarray>[ [ 1, 2 ], [ 3, 4 ] ]The function accepts the following arguments:
- x: input ndarray.
- The function always returns a new ndarray instance even if the input ndarray does not contain any singleton dimensions.
var uniform = require( '@stdlib/random/uniform' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var removeSingletonDimensions = require( '@stdlib/ndarray/remove-singleton-dimensions' );
var x = uniform( [ 1, 1, 3, 3, 3 ], -10.0, 10.0 );
console.log( ndarray2array( x ) );
var y = removeSingletonDimensions( x );
console.log( ndarray2array( y ) );