function cummax
cummax(x: array): array

Cumulative maximum of array elements.

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

Examples

Cumulative maximum of a 1D array

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

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

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

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

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

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

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

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

Parameters

The input array or matrix of values

Return Type

The cumulative maximum of the input values

Throws

If no input is provided

cummax(
x: array,
dim?: 0 | 1,
): array

Cumulative maximum of array elements.

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

Examples

Cumulative maximum of a 1D array

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

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

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

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

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

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

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

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

Parameters

The input array or matrix of values

optional
dim: 0 | 1

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

Return Type

The cumulative maximum of the input values

Throws

If no input is provided

cummax(
x: matrix,
dim?: 0 | 1,
): matrix

Cumulative maximum of array elements.

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

Examples

Cumulative maximum of a 1D array

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

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

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

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

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

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

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

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

Parameters

The input array or matrix of values

optional
dim: 0 | 1

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

Return Type

The cumulative maximum of the input values

Throws

If no input is provided