Multik 0.3.0 Help

count

Returns the total number of elements in the array, or the number of elements matching the given predicate.

Signatures

inline fun <T, D : Dimension> MultiArray<T, D>.count(): Int inline fun <T, D : Dimension> MultiArray<T, D>.count( predicate: (T) -> Boolean ): Int

Parameters

Parameter

Type

Description

predicate

(T) -> Boolean

Condition to count matching elements.

Returns:

  • Without predicate: total number of elements.

  • With predicate: number of elements satisfying predicate.

Example

val a = mk.ndarray(mk[1, 2, 3, 4, 5]) a.count() // 5 a.count { it > 3 } // 2
28 February 2026