envzn
0.8 · beta · not released

Library / Collections / Sequences / NativeNdArray

CLASS

NativeNdArray

NativeNdArray — what T[,] (any rank, runtime extents) is.

Constructors 1

INIT(REFERENCE int64[] extents)

T[m, n, …]: one extent per axis (1 to 15), every cell EMPTY / zero, or a value class's default (its INIT(), E1159). An extent is int64 in the language and int32 in the store; a negative one, or one past int32, is a MathError, never an empty axis (§11).

Methods 14

METHOD count() RETURNS int64
reads

The cells: the extents multiplied out.

METHOD rank() RETURNS int64
reads

The axes.

METHOD dim(int64 k) RETURNS int64
reads

The extent of axis k.

METHOD stride(int64 k) RETURNS int64
reads

The column-major stride of axis k: the product of every extent below it.

METHOD isContiguous() RETURNS boolean
reads

A native N-D array is one dense column-major block.

MODIFY METHOD fill(REFERENCE T v) RETURNS void
modifies

Every cell becomes a copy of v; the caller keeps v.

MODIFY METHOD swap(int64 coords...) RETURNS void
modifies

Exchange two cells, given as the full coordinates of both: rank for the first, then rank for the second (grid->swap(i0, j0, i1, j1)).

MODIFY METHOD reshapeTo(int64 extents...) RETURNS boolean
modifies

Re-extent to extents, one per axis, when the cell count is unchanged; no cell moves. FALSE, with the array unchanged, when the count differs (a negative extent counts as zero).

METHOD equals(REFERENCE NativeNdArray[T] other) RETURNS boolean
reads

The same extents and every cell equal.

METHOD clone() RETURNS NativeNdArray[T]
reads

A deep copy: the same extents, and each cell's own copy.

METHOD copyInto(MUTABLE REFERENCE NativeNdArray[T] dest) RETURNS void
reads

Copy every cell into dest, which has as many: each cell dest held is dropped and replaced by its own copy of this array's cell, and an EMPTY cell stays EMPTY (§7). It is how a whole-array value reaches a fixed T[M,N], which is C's cells and has no copy of its own: float64[2,2] fp := p * q copies the product into a view of fp (native-array-primitive-design §19.13, Brian).

METHOD __op_plus__(REFERENCE NativeNdArray[T] other) RETURNS NativeNdArray[T]
reads

a + b, a - b, a * b: element by element over two arrays of one shape (a Hadamard product, not a matrix one — linear algebra is AdvancedMath's). The analyzer refuses unequal ranks (E2125) and a non-numeric element (E2132).

METHOD __op_minus__(REFERENCE NativeNdArray[T] other) RETURNS NativeNdArray[T]
reads
METHOD __op_times__(REFERENCE NativeNdArray[T] other) RETURNS NativeNdArray[T]
reads