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

Number of array dimensions.

Calculates the number of dimensions of an array or matrix by determining the length of the size array.

Examples

1D array

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

assertEquals(ndims([3, 5, 6]), 2);

2D array

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

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

Parameters

Array or matrix of elements.

Return Type

number

The number of dimensions of the array.

Throws

If no input is provided.

Usage

import ndims from "matarrs/ndims.ts";