sparse2d
def sparse2d(
a
):Create a 2D sparse array in specified format.
[<Compressed Sparse Row sparse array of dtype 'float64'
with 2 stored elements and shape (2, 2)>,
<Compressed Sparse Row sparse array of dtype 'float64'
with 2 stored elements and shape (2, 2)>,
<Compressed Sparse Row sparse array of dtype 'float64'
with 2 stored elements and shape (2, 2)>,
<Compressed Sparse Row sparse array of dtype 'float64'
with 2 stored elements and shape (2, 2)>]
Create an N-D sparse array in specified format.
[<COO: shape=(2, 2), dtype=float64, nnz=2, fill_value=0.0>,
<GCXS: shape=(2, 2), dtype=float64, nnz=2, fill_value=0.0, compressed_axes=(np.int64(0),)>,
<COO: shape=(2, 2), dtype=float64, nnz=2, fill_value=0.0>,
<GCXS: shape=(2, 2), dtype=float64, nnz=2, fill_value=0.0, compressed_axes=(0,)>,
<COO: shape=(2, 2), dtype=float64, nnz=2, fill_value=0.0>,
<GCXS: shape=(2, 2), dtype=float64, nnz=2, fill_value=0.0, compressed_axes=(np.int64(0),)>,
<COO: shape=(2, 2), dtype=float64, nnz=2, fill_value=0.0>,
<GCXS: shape=(2, 2), dtype=float64, nnz=2, fill_value=0.0, compressed_axes=(np.int64(0),)>]
<DIAgonal sparse array of dtype 'float64'
with 2 stored elements (1 diagonals) and shape (2, 2)>
[<COO: shape=(2, 2), dtype=float64, nnz=2, fill_value=0.0>,
<GCXS: shape=(2, 2), dtype=float64, nnz=2, fill_value=0.0, compressed_axes=(np.int64(0),)>]
/var/folders/zd/dnb1yww92mn4qyg7_lww7g9m0000gn/T/ipykernel_33348/2086511523.py:3: FutureWarning: Input has data type int64, but the output has been cast to float64. In the future, the output data type will match the input. To avoid this warning, set the `dtype` parameter to `None` to have the output dtype match the input, or set it to the desired output data type.
return sps.diags_array(diags, offsets=offsets)
<DIAgonal sparse array of dtype 'float64'
with 2 stored elements (1 diagonals) and shape (2, 2)>
/var/folders/zd/dnb1yww92mn4qyg7_lww7g9m0000gn/T/ipykernel_33348/2086511523.py:3: FutureWarning: Input has data type int64, but the output has been cast to float64. In the future, the output data type will match the input. To avoid this warning, set the `dtype` parameter to `None` to have the output dtype match the input, or set it to the desired output data type.
return sps.diags_array(diags, offsets=offsets)
| Format | coo |
|---|---|
| Data Type | float64 |
| Shape | (2, 2) |
| nnz | 2 |
| Density | 0.5 |
| Read-only | True |
| Size | 32 |
| Storage ratio | 1.00 |
Return a toeplitz array given the value on each diagonal (starting at lower left).
Return a toeplitz sparse array in specified format given the value on each diagonal (starting at lower left).
| Format | coo |
|---|---|
| Data Type | int64 |
| Shape | (3, 3) |
| nnz | 9 |
| Density | 1.0 |
| Read-only | True |
| Size | 216 |
| Storage ratio | 3.00 |
The nxn sparse kronecker matrix delta_(i,j-k) in specified format.
<DIAgonal sparse array of dtype 'float64'
with 1 stored elements (1 diagonals) and shape (3, 3)>
The nxn sparse kronecker matrix delta_(i,j-k) in specified format.
| Format | coo |
|---|---|
| Data Type | float64 |
| Shape | (3, 3) |
| nnz | 1 |
| Density | 0.1111111111111111 |
| Read-only | True |
| Size | 16 |
| Storage ratio | 0.22 |
array([[1., 0., 0., 0., 0., 0., 0., 0.],
[0., 1., 0., 0., 0., 0., 0., 0.],
[0., 0., 1., 0., 0., 0., 0., 0.],
[0., 0., 0., 1., 0., 0., 0., 0.],
[0., 0., 0., 0., 1., 0., 0., 0.],
[0., 0., 0., 0., 0., 1., 0., 0.],
[0., 0., 0., 0., 0., 0., 1., 0.],
[0., 0., 0., 0., 0., 0., 0., 1.]])
<Compressed Sparse Row sparse array of dtype 'float64'
with 8 stored elements and shape (8, 8)>
<Compressed Sparse Row sparse array of dtype 'float64'
with 8 stored elements and shape (8, 8)>
<COOrdinate sparse array of dtype 'float64'
with 0 stored elements and shape (2, 3)>
Make a scipy sparse array banded by setting all elements outside the bandwidth to zero.
<Compressed Sparse Row sparse array of dtype 'float64'
with 13 stored elements and shape (5, 5)>