numel
Return the number of elements in an array.
Usage
var numel = require( '@stdlib/ndarray/base/numel' );
numel( shape )
Returns the number of elements in an array.
var n = numel( [ 3, 2, 3 ] );
// returns 18
Examples
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var numel = require( '@stdlib/ndarray/base/numel' );
var shape;
var n;
var i;
shape = [ 0, 0, 0 ];
for ( i = 0; i < 100; i++ ) {
// Generate random NxMxL dimensions:
shape[ 0 ] = discreteUniform( 1, 10 );
shape[ 1 ] = discreteUniform( 2, 7 );
shape[ 2 ] = discreteUniform( 1, 12 );
n = numel( shape );
console.log( '%s => %d elements', shape.join( 'x' ), n );
}