Nocturnally Psychologizing Millipede

    @stdlib/ndarray-base-numel
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.8 • Public • Published

    numel

    NPM version Build Status Coverage Status

    Return the number of elements in an array.

    Installation

    npm install @stdlib/ndarray-base-numel

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

    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

    Chat


    License

    See LICENSE.

    Copyright

    Copyright © 2016-2022. The Stdlib Authors.

    Install

    npm i @stdlib/ndarray-base-numel

    Homepage

    stdlib.io

    DownloadsWeekly Downloads

    1,674

    Version

    0.0.8

    License

    Apache-2.0

    Unpacked Size

    38.6 kB

    Total Files

    12

    Last publish

    Collaborators

    • stdlib-bot
    • kgryte
    • planeshifter
    • rreusser