function cummin
cummin(x: array): array

Cumulative minimum of array elements.

Computes the cumulative minimum of elements in an array or matrix along a specified dimension.

Examples

Cumulative minimum of a 1D array

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

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

Cumulative minimum of a matrix along columns (dim=1)

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

assertEquals(cummin([[5, 6, 5], [7, 8, -1]], 1), [[5, 5], [6, 6], [5, -1]]);

Cumulative minimum of a matrix along rows (dim=0)

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

assertEquals(cummin([[5, 6, 5], [7, 8, -1]], 0), [[5, 5, 5], [7, 7, -1]]);

Parameters

The input array or matrix of values

Return Type

The cumulative minimum of the input values

Throws

If no input is provided

cummin(
x: array,
dim: 0,
): array

Cumulative minimum of array elements.

Computes the cumulative minimum of elements in an array or matrix along a specified dimension.

Examples

Cumulative minimum of a 1D array

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

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

Cumulative minimum of a matrix along columns (dim=1)

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

assertEquals(cummin([[5, 6, 5], [7, 8, -1]], 1), [[5, 5], [6, 6], [5, -1]]);

Cumulative minimum of a matrix along rows (dim=0)

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

assertEquals(cummin([[5, 6, 5], [7, 8, -1]], 0), [[5, 5, 5], [7, 7, -1]]);

Parameters

The input array or matrix of values

dim: 0

The dimension along which to calculate, 1 for columns, 0 for rows (defaults to 1)

Return Type

The cumulative minimum of the input values

Throws

If no input is provided

cummin(
x: array,
dim: 1,
): array

Cumulative minimum of array elements.

Computes the cumulative minimum of elements in an array or matrix along a specified dimension.

Examples

Cumulative minimum of a 1D array

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

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

Cumulative minimum of a matrix along columns (dim=1)

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

assertEquals(cummin([[5, 6, 5], [7, 8, -1]], 1), [[5, 5], [6, 6], [5, -1]]);

Cumulative minimum of a matrix along rows (dim=0)

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

assertEquals(cummin([[5, 6, 5], [7, 8, -1]], 0), [[5, 5, 5], [7, 7, -1]]);

Parameters

The input array or matrix of values

dim: 1

The dimension along which to calculate, 1 for columns, 0 for rows (defaults to 1)

Return Type

The cumulative minimum of the input values

Throws

If no input is provided

cummin(
x: matrix,
dim: 0,
): matrix

Cumulative minimum of array elements.

Computes the cumulative minimum of elements in an array or matrix along a specified dimension.

Examples

Cumulative minimum of a 1D array

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

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

Cumulative minimum of a matrix along columns (dim=1)

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

assertEquals(cummin([[5, 6, 5], [7, 8, -1]], 1), [[5, 5], [6, 6], [5, -1]]);

Cumulative minimum of a matrix along rows (dim=0)

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

assertEquals(cummin([[5, 6, 5], [7, 8, -1]], 0), [[5, 5, 5], [7, 7, -1]]);

Parameters

The input array or matrix of values

dim: 0

The dimension along which to calculate, 1 for columns, 0 for rows (defaults to 1)

Return Type

The cumulative minimum of the input values

Throws

If no input is provided

cummin(
x: matrix,
dim: 1,
): matrix

Cumulative minimum of array elements.

Computes the cumulative minimum of elements in an array or matrix along a specified dimension.

Examples

Cumulative minimum of a 1D array

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

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

Cumulative minimum of a matrix along columns (dim=1)

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

assertEquals(cummin([[5, 6, 5], [7, 8, -1]], 1), [[5, 5], [6, 6], [5, -1]]);

Cumulative minimum of a matrix along rows (dim=0)

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

assertEquals(cummin([[5, 6, 5], [7, 8, -1]], 0), [[5, 5, 5], [7, 7, -1]]);

Parameters

The input array or matrix of values

dim: 1

The dimension along which to calculate, 1 for columns, 0 for rows (defaults to 1)

Return Type

The cumulative minimum of the input values

Throws

If no input is provided