Array fundamentals
Overview
This page introduces the NDArray model, its core properties, and the basic arithmetic and indexing workflow you will use throughout Multik.
NDArray essentials
An NDArray is Multik's core data type for dense, homogeneous numeric data. It is defined by four key properties:
Dimension (
dim) — number of axes, such asD1,D2,D3,D4, orDN.Shape (
shape) — sizes of each axis, for example(2, 3).Size (
size) — total number of elements.DType (
dtype) — element type, such asInt,Double, or complex types.
These properties help keep computations correct and predictable.
Creating arrays
For quick creation, use mk[] with mk.ndarray and let Multik infer type and dimension:
You can also use factory methods like zeros, ones, and identity. For a deeper overview, see Creating multidimensional arrays.
Inspecting properties
Element-wise arithmetic
Arithmetic is element-wise by default:
When operating on two arrays, their shapes must match. For fixed dimensions (D1-D4), dimension mismatch is caught at compile time; shape mismatch is checked at runtime.
Matrix product with dot
* is element-wise. For matrix multiplication use dot:
In-place operations
Operations like +=, -=, *=, and /= modify the current array:
Indexing and slicing
Indexing uses zero-based indices and works per axis:
For ranges, slices, and multi-axis selection, see Indexing and slicing.