Expand description
Sparse arrays: the storage kind behind J’s $..
A sparse array has the shape of the array it stands for and holds only
the positions that differ from one repeated element — the SPARSE
ELEMENT, which is zero for anything sparsify makes. Some of the axes
are stored sparsely and the rest are dense, so one stored entry is a
whole cell over the dense axes: an index row naming the entry’s position
along the sparse axes, and that cell’s elements. When every axis is
sparse — what $. y always produces — the cell is a single element and
the array is the familiar list of coordinates and values.
The shape and the stored values live on the Array itself: shape is
the LOGICAL shape and data is the stored cells end to end, so an array
of sparse doubles reports the same dtype and formats its values through
the same code a dense one does. Everything else is in Sparse, which
the array carries behind an Arc.
Only $. itself, the display and ": read the stored form. Every other
verb receives Array::densified, which is semantically exact and says
nothing about how fast it is; the caveat is written down in
docs/status.md.
Structs§
- Sparse
- What a sparse array holds besides its shape and its stored cells.
Functions§
- attributes
- The shape, the sparse axes and the sparse element, each boxed. This is
_1 $. y. - compress
8 $. y: the same array with every stored entry whose cell is entirely the sparse element dropped. Amending a stored position back to the fill leaves the entry behind; this is what removes it.- create
1 $. y: a new sparse array with nothing stored in it.yis the shape, or a boxedshape ; axes, or a boxedshape ; axes ; element. Left to itself the whole shape is sparse and the element is a float zero, which is what J’s own bare form gives.- fill_of
- The sparse element on its own, as an atom. This is
3 $. y. - indices_
of - The stored index rows as an integer table: one row per entry, one column
per sparse axis. This is
4 $. y. - sparsify
$. y: the dense arrayyin sparse form, every axis sparse and zero the sparse element. A sparse argument comes back unchanged, and a scalar stays dense — there is no axis to store it along.- values_
of - The stored cells as an ordinary array: one leading axis of entries, then
the cell’s own shape. This is
5 $. y.