Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "ndarray/base/remove-singleton-dimensions/docs/types/index.d"

Index

Functions

Export assignment removeSingletonDimensions

  • Returns an array without singleton dimensions.

    Notes

    • If a provided ndarray does not have any singleton dimensions, the function returns the provided ndarray unchanged.
    • If a provided ndarray does have singleton dimensions, the function returns a new ndarray view.

    Parameters

    Returns ndarray

    squeezed array

    Example

    var array = require( `@stdlib/ndarray/array` );
    
    var x = array( [ [ 1, 2 ], [ 3, 4 ] ], {
        'ndmin': 5
    });
    // returns <ndarray>
    
    var shx = x.shape;
    // returns [ 1, 1, 1, 2, 2 ]
    
    var y = removeSingletonDimensions( x );
    // returns <ndarray>
    
    var shy = y.shape;
    // returns [ 2, 2 ]
    
    var v = y.get( 0, 0 );
    // returns 1
    
    v = y.get( 0, 1 );
    // returns 2
    
    v = y.get( 1, 0 );
    // returns 3
    
    v = y.get( 1, 1 );
    // returns 4