irfpy.util.ndsparse
¶
Multidimensional sparse array.
Interface could be very similar to scipy:scipy.sparse.dok_matrix
.
However, this class is developed “on demand”, so that the implementation
is not fully completed.
Code author: Yoshifumi Futaana
- class irfpy.util.ndsparse.ndsparse_container(arg1)[source]¶
Bases:
object
N-dimensional sparse array.
This class provide a container part.
Construct multi-dimensional sparse array.
From a dense array:
>>> mat = ndsparse([[0, 0, 0, 0, 2], [0, 3, 0, 0, 1], [0, 1, -1, 0, 0]])
will create (3, 5) shaped array.
>>> print(mat.shape) (3, 5)
From a sparse array
>>> mat2 = ndsparse(mat) >>> print(mat2.shape) (3, 5)
By specifying the shape, if
arg1
is a tuple.
>>> mat3 = ndsparse((5, 3, 2)) >>> print(mat3.shape) (5, 3, 2)
- class irfpy.util.ndsparse.ndsparse(arg1, **argv)[source]¶
Bases:
object
N-dimensional sparse array.
Create a sparse array container.
See
ndsparse_container
.