time-to-botec/js/node_modules/@stdlib/ndarray/base/numel
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00
..
docs feat: add the node modules 2022-12-03 12:44:49 +00:00
include/stdlib/ndarray/base feat: add the node modules 2022-12-03 12:44:49 +00:00
lib feat: add the node modules 2022-12-03 12:44:49 +00:00
src feat: add the node modules 2022-12-03 12:44:49 +00:00
manifest.json feat: add the node modules 2022-12-03 12:44:49 +00:00
package.json feat: add the node modules 2022-12-03 12:44:49 +00:00
README.md feat: add the node modules 2022-12-03 12:44:49 +00:00

numel

Return the number of elements in an array.

Usage

var numel = require( '@stdlib/ndarray/base/numel' );

numel( shape )

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