Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

removeSingletonDimensions

Return a read-only view of an input ndarray with singleton dimensions removed.

Usage

var removeSingletonDimensions = require( '@stdlib/ndarray/remove-singleton-dimensions' );

removeSingletonDimensions( x )

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:

Notes

  • The function always returns a new ndarray instance even if the input ndarray does not contain any singleton dimensions.

Examples

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 ) );