ndarray
Overview
mk.ndarray() is the most common way to create arrays. It infers type and dimension from the input. Use mk[...] to build nested list literals inline.
From nested lists with mk[]
Overloads exist for 1D–4D with both Number and Complex element types.
From collection with shape
Parameter | Type | Description |
|---|---|---|
|
| Flat collection of values. |
|
| Target shape. Product must equal |
Dimension can be reified or passed explicitly:
From collection with dimension sizes
Overloads for 2D, 3D, 4D, and N-D (5+ dimensions via varargs).
From primitive arrays
1D:
With shape:
Supported types: ByteArray, ShortArray, IntArray, LongArray, FloatArray, DoubleArray, ComplexFloatArray, ComplexDoubleArray.
From Array of primitive arrays
Pitfalls
The product of the shape must exactly equal the number of elements. A mismatch throws
IllegalArgumentException.Nested list inputs are validated for consistent sizes — jagged lists are rejected.