# Sparse 3D arrays

**URL:** https://discourse.julialang.org/t/sparse-3d-arrays/16488
**Category:** General Usage
**Tags:** question, sparse, sparsearrays
**Created:** [October 18, 2018, 12:22pm UTC](https://discourse.julialang.org/t/sparse-3d-arrays/16488 "2018-10-18T12:22:05Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)
#### Post date: [October 18, 2018, 12:22pm UTC](https://discourse.julialang.org/t/sparse-3d-arrays/16488/1 "2018-10-18T12:22:06Z")

</div>

It seems that `SparseArrays` only offers sparse vectors and matrices. Are there packages for higher dimensional sparse arrays? I am mainly interested in 3d.

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [October 18, 2018, 12:45pm UTC](https://discourse.julialang.org/t/sparse-3d-arrays/16488/2 "2018-10-18T12:45:01Z")

</div>

What do you need it for, i.e. what operations do you need? Maybe you can just use a `Dict`?

---

<div class="post-metadata">

### Author: ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)
#### Post date: [October 18, 2018, 12:47pm UTC](https://discourse.julialang.org/t/sparse-3d-arrays/16488/3 "2018-10-18T12:47:37Z")

</div>

Maybe [NDSparse](https://juliadb.org/latest/api/datastructures.html#NDSparse-1) from IndexedTables?

---

<div class="post-metadata">

### Author: ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)
#### Post date: [October 18, 2018, 12:55pm UTC](https://discourse.julialang.org/t/sparse-3d-arrays/16488/4 "2018-10-18T12:55:47Z")

</div>

May main concern is to save memory. For arithmetic I have modest wishes. I mainly need to be able to do arithmetic with slices and views (being able to convert them to full is enough). So indeed this could be implemented by wrapping a `Dict`.

---

<div class="post-metadata">

### Author: ![jwu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jwu/32/3775_2.png) [@jwu](https://discourse.julialang.org/u/jwu)
#### Post date: [October 18, 2018, 1:39pm UTC](https://discourse.julialang.org/t/sparse-3d-arrays/16488/5 "2018-10-18T13:39:09Z")

</div>

NDSparse do not have slicing interface. Should not be difficult to make one though.

---

<div class="post-metadata">

### Author: ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)
#### Post date: [October 19, 2018, 9:13am UTC](https://discourse.julialang.org/t/sparse-3d-arrays/16488/6 "2018-10-19T09:13:27Z")

</div>

I put together a package following @fredrikekre [suggestion](https://discourse.julialang.org/t/sparse-3d-arrays/16488/2).  
[https://github.com/jw3126/SimpleSparseArrays.jl](https://github.com/jw3126/SimpleSparseArrays.jl)

---

<div class="post-metadata">

### Author: ![jovansam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jovansam/32/15023_2.png) [@jovansam](https://discourse.julialang.org/u/jovansam)
#### Post date: [June 21, 2020, 7:34am UTC](https://discourse.julialang.org/t/sparse-3d-arrays/16488/7 "2020-06-21T07:34:34Z")

</div>

@jw3126, @fredrikekre. I landed here looking for 3-d sparse arrays. Why not integrate “SimpleSparseArrays” functionality into SparseArrays. I do not see why the latter would have only upto 2-d functionality.

---

<div class="post-metadata">

### Author: ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)
#### Post date: [June 22, 2020, 11:40am UTC](https://discourse.julialang.org/t/sparse-3d-arrays/16488/8 "2020-06-22T11:40:27Z")

</div>

I think it would indeed be nice to have a goto package for nd sparse arrays. I don’t have a strong opinion on whether such a package should be in the stdlib or not. But it would need to be more polished than “SimpleSparseArrays” in its current form, before it could go to stdlib.

---

<div class="post-metadata">

### Author: ![racinmat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/racinmat/32/11715_2.png) [@racinmat](https://discourse.julialang.org/u/racinmat)
#### Post date: [December 17, 2020, 10:32pm UTC](https://discourse.julialang.org/t/sparse-3d-arrays/16488/9 "2020-12-17T22:32:04Z")

</div>

I found [https://github.com/Jutho/SparseArrayKit.jl](https://github.com/Jutho/SparseArrayKit.jl) which is registered in registry, and works well with newer versions of Julia.

---

<div class="post-metadata">

### Author: ![raphasampaio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raphasampaio/32/218602_2.png) [@raphasampaio](https://discourse.julialang.org/u/raphasampaio)
#### Post date: [September 17, 2025, 2:18am UTC](https://discourse.julialang.org/t/sparse-3d-arrays/16488/10 "2025-09-17T02:18:16Z")

</div>

There’s an n-dimensional sparse array package that might be useful: [GitHub - JuliaSparse/NDimensionalSparseArrays.jl: A Julia package for n-dimensional sparse arrays](https://github.com/JuliaSparse/NDimensionalSparseArrays.jl)

The main difference from similar packages is that it comes with no dependencies.

---

<div class="post-metadata">

### Author: ![rayegun](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rayegun/32/26729_2.png) [@rayegun](https://discourse.julialang.org/u/rayegun)
#### Post date: [September 17, 2025, 7:17am UTC](https://discourse.julialang.org/t/sparse-3d-arrays/16488/11 "2025-09-17T07:17:41Z")

</div>

> @jw3126, @fredrikekre. I landed here looking for 3-d sparse arrays. Why not integrate “SimpleSparseArrays” functionality into SparseArrays. I do not see why the latter would have only upto 2-d functionality.

Note to necro this thread but:

The SparseArrays stdlib is a fantastic library but shows it’s age in many ways. It is largely an interface to older SuiteSparse solvers, and is entirely based on one structure: the CSC matrix.

While it would be nice to have one single sparse library for the entire ecosystem, SparseArrays.jl is stuck on the 1.x series and cannot be broken. That leaves essentially no room for experimentation with new interfaces, structures, and functions. It is also a fairly fragile library, making pretty important assumptions like the existence of a zero and is hard to maintain with respect to the broadcast system especially. And it can never take advantage of parallelism in the 1.x series dramatically limiting performance.

For those reasons I have encouraged people to build their sparse experiments and libraries outside of the stdlib, and a lot of good packages have come out of that like Finch.jl, SuiteSparseGraphBLAS.jl (undermaintained right now but a new release should be out soon), SparseArrayKit.jl, and now NDimensionalSparseArrays.jl!
