Multik 0.3.0 Help

max

Returns the largest element in the array, or null if the array is empty. maxBy and maxWith variants allow custom comparison via a selector function or a Comparator.

Signatures

fun <T : Number, D : Dimension> MultiArray<T, D>.max(): T? inline fun <T, D : Dimension, R : Comparable<R>> MultiArray<T, D>.maxBy( selector: (T) -> R ): T? fun <T, D : Dimension> MultiArray<T, D>.maxWith( comparator: Comparator<in T> ): T?

Parameters

Parameter

Type

Description

selector

(T) -> R

Maps each element to a comparable value for ranking.

comparator

Comparator<in T>

Custom comparator for ordering.

Returns: The largest element, or null if the array is empty.

Example

val a = mk.ndarray(mk[3, 1, 4, 1, 5]) a.max() // 5 a.maxBy { -it } // 1 (largest by negated value) a.maxWith(compareBy { it }) // 5
28 February 2026