Multik 0.3.0 Help

Comparison operations

Overview

Comparison operations take two arrays of the same shape and return a new array where each element is the result of an element-wise comparison. Multik provides minimum and maximum.

minimum

fun <T : Number, D : Dimension> MultiArray<T, D>.minimum( other: MultiArray<T, D> ): NDArray<T, D>

Returns a new array where each element is the smaller of the two corresponding elements.

Example

val a = mk.ndarray(mk[1, 5, 3]) val b = mk.ndarray(mk[4, 2, 6]) val c = a.minimum(b) // [1, 2, 3]

maximum

fun <T : Number, D : Dimension> MultiArray<T, D>.maximum( other: MultiArray<T, D> ): NDArray<T, D>

Returns a new array where each element is the larger of the two corresponding elements.

Example

val a = mk.ndarray(mk[1, 5, 3]) val b = mk.ndarray(mk[4, 2, 6]) val c = a.maximum(b) // [4, 5, 6]

Pitfalls

  • Both arrays must have the same shape.

  • Complex types (ComplexFloat, ComplexDouble) are not supported — throws UnsupportedOperationException.

  • For single-array min/max, see max and min.

28 February 2026