Skip to content

Commit 45b8640

Browse files
committed
Initial commit
2 parents 1fd2152 + 9ca36ba commit 45b8640

24 files changed

+283
-285
lines changed

README.md

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,27 @@
66

77
## Overview
88

9-
`NDimensionalSparseArrays.jl` provides a `SparseArray` type that efficiently stores and manipulates multidimensional arrays with a high proportion of zero elements. Unlike dense arrays, `SparseArray` only stores non-zero values, significantly reducing memory consumption for sparse data.
9+
`NDimensionalSparseArrays.jl` provides a `NDSparseArray` type that efficiently stores and manipulates multidimensional arrays with a high proportion of zero elements. Unlike dense arrays, `NDSparseArray` only stores non-zero values, significantly reducing memory consumption for sparse data.
1010

1111
This package is designed to be a flexible and intuitive tool for scientific computing, data analysis, and any domain where large, sparse multidimensional data structures are common.
1212

13-
## Comparison with `SparseArrays.jl`
14-
15-
`NDimensionalSparseArrays.jl` is designed to provide a flexible and easy-to-use interface for N-dimensional sparse arrays. While Julia's standard library [`SparseArrays.jl`](https://github.com/JuliaSparse/SparseArrays.jl) is highly optimized for 1-D and 2-D sparse arrays (vectors and matrices), `NDimensionalSparseArrays.jl` offers a more general-purpose solution for higher-dimensional sparse data.
16-
17-
Key differences include:
18-
19-
- **Dimensionality:** `SparseArrays.jl` focuses on `SparseVector` and `SparseMatrixCSC`. `NDimensionalSparseArrays.jl` is built from the ground up for N-dimensional arrays.
20-
- **Storage Format:** `NDimensionalSparseArrays.jl` uses a dictionary-based storage (`Dict{CartesianIndex{N}, T}`), which is flexible for arbitrary dimensions. `SparseArrays.jl` uses the more rigid but highly efficient Compressed Sparse Column (CSC) format for matrices.
21-
- **Use Case:** If you are working with 1-D or 2-D sparse arrays and require high-performance linear algebra operations, `SparseArrays.jl` is the ideal choice. If you need to work with sparse data in three or more dimensions, `NDimensionalSparseArrays.jl` provides a more natural and convenient API.
22-
2313
## Features
2414

2515
- **Memory Efficiency:** Only non-zero elements are stored, making it ideal for high-dimensional sparse data.
2616
- **Arbitrary Dimensionality:** Create sparse arrays of any number of dimensions.
2717
- **Intuitive Indexing:** Use standard Julia indexing to access and modify elements.
2818
- **Comprehensive API:** A rich set of functions for creating, manipulating, and analyzing sparse arrays.
29-
- **Interoperability:** Easily convert between `SparseArray` and dense `Array` types.
19+
- **Interoperability:** Easily convert between `NDSparseArray` and dense `Array` types.
3020
- **Arithmetic Operations:** Perform element-wise arithmetic (+, -, *) on sparse arrays.
3121

22+
## Comparison with `SparseArrays.jl`
23+
24+
`NDimensionalSparseArrays.jl` is designed to provide a flexible and easy-to-use interface for N-dimensional sparse arrays. While Julia's standard library [`SparseArrays.jl`](https://github.com/JuliaSparse/SparseArrays.jl) is highly optimized for 1-D and 2-D sparse arrays (vectors and matrices), `NDimensionalSparseArrays.jl` offers a more general-purpose solution for higher-dimensional sparse data. Key differences include:
25+
26+
- **Dimensionality:** `SparseArrays.jl` focuses on `SparseVector` and `SparseMatrixCSC`. `NDimensionalSparseArrays.jl` is built from the ground up for N-dimensional arrays.
27+
- **Storage Format:** `NDimensionalSparseArrays.jl` uses a dictionary-based storage (`Dict{CartesianIndex{N}, T}`), which is flexible for arbitrary dimensions. `SparseArrays.jl` uses the more rigid but highly efficient Compressed Sparse Column (CSC) format for matrices.
28+
- **Use Case:** If you are working with 1-D or 2-D sparse arrays and require high-performance linear algebra operations, `SparseArrays.jl` is the ideal choice. If you need to work with sparse data in three or more dimensions, `NDimensionalSparseArrays.jl` provides a more natural and convenient API.
29+
3230
## Installation
3331

3432
```julia
@@ -37,19 +35,19 @@ pkg> add NDimensionalSparseArrays
3735

3836
## Usage
3937

40-
### Creating a SparseArray
38+
### Creating a NDSparseArray
4139

42-
You can create a `SparseArray` in several ways:
40+
You can create a `NDSparseArray` in several ways:
4341

4442
```julia
4543
using NDimensionalSparseArrays
4644

4745
# Create an empty 3x4x2 sparse array of Float64
48-
A = SparseArray{Float64}(3, 4, 2)
46+
A = NDSparseArray{Float64}(3, 4, 2)
4947

5048
# Create from a dense array (only non-zero elements are stored)
5149
dense_array = [1 0 3; 0 0 0; 2 0 0]
52-
B = SparseArray(dense_array)
50+
B = NDSparseArray(dense_array)
5351

5452
# Create a sparse array of zeros
5553
C = spzeros(Int, 5, 5)
@@ -63,7 +61,7 @@ D = spones(2, 2)
6361
Use standard array indexing to get and set elements. Accessing an unset element will throw a `BoundsError`.
6462

6563
```julia
66-
A = SparseArray{Float64}(3, 3)
64+
A = NDSparseArray{Float64}(3, 3)
6765

6866
# Set values
6967
A[1, 1] = 10.0
@@ -108,8 +106,8 @@ compress!(B)
108106
Element-wise arithmetic operations are supported:
109107

110108
```julia
111-
A = SparseArray([1 0; 0 4])
112-
B = SparseArray([0 2; 3 0])
109+
A = NDSparseArray([1 0; 0 4])
110+
B = NDSparseArray([0 2; 3 0])
113111

114112
# Addition
115113
C = A + B # [1 2; 3 4]
@@ -125,7 +123,7 @@ E = A * 2 # [2 0; 0 8]
125123

126124
The following are the key exports of the package:
127125

128-
- `SparseArray`: The multidimensional sparse array type.
126+
- `NDSparseArray`: The multidimensional sparse array type.
129127
- `nnz`: Get the number of non-zero elements.
130128
- `sparsity`: Get the fraction of zero elements.
131129
- `stored_indices`, `stored_values`, `stored_pairs`: Iterators for stored elements.

src/NDimensionalSparseArrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module NDimensionalSparseArrays
22

33
include("ndsparsearray.jl")
44

5-
export SparseArray, nnz, sparsity, stored_indices, stored_values, stored_pairs,
5+
export NDSparseArray, nnz, sparsity, stored_indices, stored_values, stored_pairs,
66
spzeros, spones, spfill, findnz, dropstored!, compress!, hasindex, to_dense
77

88
end

0 commit comments

Comments
 (0)