function numel
numel(x: array | matrix): number

Number of elements in an array or matrix.

Computes the total number of elements in an array or matrix.

Examples

Number of elements in a vector

import { assertEquals } from "jsr:@std/assert";

assertEquals(numel([3, 5, 6]), 3);

Number of elements in a matrix

import { assertEquals } from "jsr:@std/assert";

assertEquals(numel([[3, 2, 7], [4, 5, 6]]), 6);

Number of elements in a 1x1 matrix

import { assertEquals } from "jsr:@std/assert";

assertEquals(numel([[42]]), 1);

Number of elements in an empty array

import { assertEquals } from "jsr:@std/assert";

assertEquals(numel([]), 0);

Parameters

The array or matrix to evaluate.

Return Type

number

The total number of elements in the array or matrix.

Throws

If no input is provided.