sparse-array.core

Operations on sparse arrays.

*safe-sparse-operations*

dynamic

Whether spase array operations should be conducted safely, with careful
checking of data conventions and exceptions thrown if expectations are not
met. Normally `false`.

arity

(arity x)
Return the arity of the sparse array `x`.

child-arity

(child-arity x)
Return the largest arity among the arities of the next dimension layer of
the sparse array `x`.

dense-array?

(dense-array? x)(dense-array? x d)
Basically, any vector can be considered as a dense array of one dimension.
If we're seeking a dense array of more than one dimension, the number of
dimensions should be specified as `d`.

dense-dimensions

(dense-dimensions x)
How many usable dimensions (represented as vectors) does the dense array
`x` have?

dense-to-sparse

(dense-to-sparse x)(dense-to-sparse x axes)
Return a sparse array representing the content of the dense array `x`,
assuming these `axes` if specified. *NOTE THAT* if insufficient
values of `axes` are specified, the resulting sparse array will
be malformed.

get

(get array & coordinates)
Return the value in this sparse `array` at these `coordinates`.

make-sparse-array

(make-sparse-array & dimensions)
Make a sparse array with these `dimensions`. Every member of `dimensions`
must be a keyword; otherwise, `nil` will be returned.

merge-arrays

(merge-arrays a1 a2)
Merge two arrays `a1`, `a2`, which may be either dense or sparse but which
should have the same number of axes and compatible dimensions, and return a
new dense array preferring values from `a2`.

merge-dense-with-sparse

(merge-dense-with-sparse d s)
Merge this dense array `d` with this sparse array `s`, returning a new
dense array with the same arity as `d`, preferring values from `s` where
there is conflict

merge-sparse-arrays

(merge-sparse-arrays a1 a2)
Return a sparse array taking values from sparse arrays `a1` and `a2`,
but preferring values from `a2` where there is a conflict. `a1` and `a2`
must have the **same** dimensions in the **same** order, or `nil` will
be returned.

put

(put array value & coordinates)
Return a sparse array like this `array` but with this `value` at these
`coordinates`. Returns `nil` if any coordinate is invalid.

sparse-array?

(sparse-array? x)(sparse-array? x & axes)
`true` if `x` is a sparse array conforming to the conventions established
by this library, else `false`.

sparse-to-dense

(sparse-to-dense x)(sparse-to-dense x arity)
Return a dense array representing the content of the sparse array `x`.

**NOTE THAT** this has the potential to consume very large amounts of memory.