Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

complementShape

Return the shape defined by the dimensions which are not included in a list of dimensions.

Usage

var complementShape = require( '@stdlib/ndarray/base/complement-shape' );

complementShape( shape, dims )

Returns the shape defined by the dimensions which are not included in a list of dimensions.

var sh = complementShape( [ 3, 2 ], [ -1 ] );
// returns [ 3 ]

The function accepts the following parameters:

  • shape: array shape.
  • dims: list of dimensions.

Examples

var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var zip = require( '@stdlib/array/base/zip' );
var filled = require( '@stdlib/array/base/filled' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var complementShape = require( '@stdlib/ndarray/base/complement-shape' );

var opts = {
    'dtype': 'int32'
};
var d1 = discreteUniform( 100, 1, 10, opts );
var d2 = discreteUniform( d1.length, 1, 10, opts );
var d3 = discreteUniform( d1.length, 1, 10, opts );
var d4 = discreteUniform( d1.length, 1, 10, opts );

var dims = discreteUniform( 2, -4, 3, opts );
var shapes = zip( [ d1, d2, d3, d4 ] );

logEachMap( 'shape: (%s). dims: (%s). complement: (%s).', shapes, filled( dims, d1.length ), complementShape );