GCXS¶
- class sparse.GCXS(arg, shape=None, compressed_axes=None, prune=False, fill_value=0, idx_dtype=None)[source]¶
A sparse multidimensional array.
This is stored in GCXS format, a generalization of the GCRS/GCCS formats from ‘Efficient storage scheme for n-dimensional sparse array: GCRS/GCCS’: https://ieeexplore.ieee.org/document/7237032. GCXS generalizes the CRS/CCS sparse matrix formats.
For arrays with ndim == 2, GCXS is the same CSR/CSC. For arrays with ndim >2, any combination of axes can be compressed, significantly reducing storage.
GCXS consists of 3 arrays. Let the 3 arrays be RO, CO and VL. The first element of array RO is the integer 0 and later elements are the number of cumulative non-zero elements in each row for GCRS, column for GCCS. CO stores column indexes of non-zero elements at each row for GCRS, column for GCCS. VL stores the values of the non-zero array elements.
The superiority of the GCRS/GCCS over traditional (CRS/CCS) is shown by both theoretical analysis and experimental results, outlined in the linked research paper.
- Parameters
arg (tuple (data, indices, indptr)) – A tuple of arrays holding the data, indices, and index pointers for the nonzero values of the array.
compressed_axes (Iterable[int]) – The axes to compress.
prune (bool, optional) – A flag indicating whether or not we should prune any fill-values present in the data array.
fill_value (scalar, optional) – The fill value for this array.
- data¶
An array holding the nonzero values corresponding to
GCXS.indices
.- Type
numpy.ndarray (nnz,)
- indices¶
An array holding the coordinates of every nonzero element along uncompressed dimensions.
- Type
numpy.ndarray (nnz,)
- indptr¶
An array holding the cumulative sums of the nonzeros along the compressed dimensions.
- Type
See also
DOK
A mostly write-only sparse array.
Attributes
The ratio of nonzero to all elements in this array.
The datatype of this array.
The imaginary part of the array.
The number of bytes taken up by this object.
The number of dimensions of this array.
The number of nonzero elements in this array.
The real part of the array.
The number of all elements (including zeros) in this array.
Methods
GCXS.__init__
(arg[, shape, compressed_axes, …])GCXS.all
([axis, keepdims, out])See if all values in an array are
True
.GCXS.amax
([axis, keepdims, out])Maximize along the given axes.
GCXS.amin
([axis, keepdims, out])Minimize along the given axes.
GCXS.any
([axis, keepdims, out])See if any values along array are
True
.GCXS.asformat
(format, **kwargs)Convert this sparse array to a given format.
GCXS.astype
(dtype[, casting, copy])Copy of the array, cast to a specified type.
GCXS.change_compressed_axes
(new_compressed_axes)Returns a new array with specified compressed axes.
GCXS.clip
([min, max, out])Clip (limit) the values in the array.
Return the complex conjugate, element-wise.
GCXS.copy
([deep])Return a copy of the array.
GCXS.dot
(other)Performs the equivalent of
x.dot(y)
forGCXS
.GCXS.flatten
([order])Returns a new
GCXS
array that is a flattened version of this array.GCXS.from_coo
(x[, compressed_axes, idx_dtype])GCXS.from_iter
(x[, shape, compressed_axes, …])GCXS.from_numpy
(x[, compressed_axes, …])GCXS.max
([axis, keepdims, out])Maximize along the given axes.
GCXS.maybe_densify
([max_size, min_density])Converts this
GCXS
array to anumpy.ndarray
if not too costly.GCXS.mean
([axis, keepdims, dtype, out])Compute the mean along the given axes.
GCXS.min
([axis, keepdims, out])Minimize along the given axes.
GCXS.prod
([axis, keepdims, dtype, out])Performs a product operation along the given axes.
GCXS.reduce
(method[, axis, keepdims])Performs a reduction operation on this array.
GCXS.reshape
(shape[, order, compressed_axes])Returns a new
GCXS
array that is a reshaped version of this array.GCXS.round
([decimals, out])Evenly round to the given number of decimals.
GCXS.round_
([decimals, out])Evenly round to the given number of decimals.
GCXS.std
([axis, dtype, out, ddof, keepdims])Compute the standard deviation along the given axes.
GCXS.sum
([axis, keepdims, dtype, out])Performs a sum operation along the given axes.
Converts this
GCXS
object into ascipy.sparse.csr_matrix
or scipy.sparse.csc_matrix.Convert this
GCXS
array to a densenumpy.ndarray
.GCXS.transpose
([axes, compressed_axes])Returns a new array which has the order of the axes switched.
GCXS.var
([axis, dtype, out, ddof, keepdims])Compute the variance along the given axes.