@stdlib/ndarray-base-complement-shape
v0.1.1
Published
Return the shape defined by the dimensions which are not included in a list of dimensions.
Readme
complementShape
Return the shape defined by the dimensions which are not included in a list of dimensions.
Installation
npm install @stdlib/ndarray-base-complement-shapeUsage
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 );Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
