ndarray::basic_ndarray
An N-dimensional array of T (a Field element type — real or complex): a view ({shape, strides, offset}) over a shared element buffer.
Copies are cheap and share the buffer; reshape/broadcast produce new views without copying elements. Index math goes through at, which bounds-checks. The element type is deduced from the data (e.g. array([1,2,3]) is integer, array([1.0,…]) is double); NDArray is the default basic_ndarray<double>. Complex element types (std::complex<double>) make complex matrices/vectors — and the complex eigenvalues a real matrix can have — first-class.
Functions
basic_ndarray · 3 overloads
Construct an empty 0-d array with a fresh empty buffer.
Leaves shape and strides empty and the buffer holding no elements; note this is distinct from a 0-d scalar (see scalar), whose buffer holds one element.
O(1).
allocates the empty shared buffer.
CheatahNDArray.ToStringScalarStdlibE2E.NdarrayThe shape (dimensions).
The element strides.
reference to the strides vector.
O(1).
none.
CheatahNDArray.BroadcastToStdlibE2E.NdarrayThe number of dimensions (rank).
The element count (product of dims; 1 for a 0-d scalar).
Recomputes the overflow-checked product of the shape on each call rather than caching it; an empty (no-dimension) shape yields 1.
the number of elements.
O(ndim).
none; throws on size overflow.
StdlibE2E.NdarrayMUTABLE element reference by multi-index — the write path behind cheatah subscript assignment x[i] = v / x[i, j] = v.
Negative indices count from the end of their dimension; rank and bounds are checked.
ixs | one (possibly negative) coordinate per dimension. |
a writable reference into the backing buffer.
O(ndim).
none.
CheatahNDArray.SubscriptReadWriteLangFeatures.NdarraySubscriptStdlibE2E.Ndarray1-D subscript: mask[i] = v assignment and raw element writes.
Accepts an integer or a scoped enum column label (see Subscript), so q[QuatCol::W] = v writes column W of a 1-D row.
i | the element index (negative counts from the end, Python-style). |
a mutable reference to element i.
O(1).
none.
CheatahNDArray.SubscriptReadWriteRead one element by a full multidimensional index (one component per axis), resolved via the array's strides.
Computes the flat buffer position as offset + sum(index[i] * strides[i]), so it correctly resolves views (including broadcast dims with stride 0). Bounds- and rank-checked.
index | the per-axis indices; its size must equal the array's rank. |
a copy of the addressed element.
std::runtime_error | if |
O(rank).
none.
StdlibE2E.NdarrayThe shared backing buffer.
reference to the element buffer shared_ptr.
O(1).
none.
CheatahNDArray.BroadcastingAddStdlibE2E.NdarrayThe flat offset into the buffer where this view starts.
the offset.
O(1).
none.
CheatahNDArray.BroadcastToStdlibE2E.NdarrayPython-style text rendering, e.g.
"[[1, 2], [3, 4]]" — the str() hook that makes an NDArray printable via io.print (io's HasStr protocol). Defers to the free to_string; defined out-of-line below, where to_string is declared.
the array formatted as nested brackets.
O(n) in the element count.
allocates the result string.
StdlibE2E.NdarrayPretty-print hook used by io.print: renders the array in nested-bracket form but ABBREVIATES a large array with ... (numpy-style edge items), so printing a big array stays readable.
io.rprint (and str()/operator<<) keep the FULL untruncated form — slice the array and rprint the subset to see everything.
os | destination stream. |
indent | unused (arrays are self-delimiting with brackets); present so |
O(printed elements).
allocates intermediate strings.
StdlibE2E.NdarrayBuild a contiguous array of shape whose buffer is sized but left UNINITIALIZED — for internal ops (binary ops, ufuncs, reshape, array) that immediately write every element, so paying for a zero-fill first is pure waste.
shape | the dimensions. |
an array of shape with an uninitialized buffer.
O(1) beyond the allocation (no element initialization).
allocates an uninitialized product(shape)-element buffer; overflow-checked.
CheatahNDArray.BroadcastingAddStdlibE2E.NdarrayConstants & variables
Types
The stored element type (an Element T).
